Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:29:49+00:00 2026-05-29T22:29:49+00:00

WordPress 3.2.1 I’m creating separate page templates, however, there are some page templates that

  • 0

WordPress 3.2.1

I’m creating separate page templates, however, there are some page templates that should have default custom fields. That is, if someone created a new page of template type “Contact Us”, it should by default have custom fields:

Success Message
Email To
Phone Number

etc.

Right now, the only way I can think of knocking this out is by having the admin add those custom fields to the page, and then fill them in. However, this isn’t the best method for basically giving an admin a “turn-key” type of feature, i.e., they create a page with a specific template and just fill in the fields.

Thanks guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:29:50+00:00Added an answer on May 29, 2026 at 10:29 pm

    The following will add 1 extra meta box to your (insert-edit) page.
    In it you can add custom fields to save.

    It does not switch depending on the selected template.
    I would recomend using javascript to show/hide fields to do this. Based on ID of the <p>

    If you get the meta box working with ALL possible fields you can show I’m willing to help with the javascript to hide and show based on the template.

    GL

    <?php    
    add_action( 'add_meta_boxes', 'carrousel_build' );
    function carrousel_build()
    {
        add_meta_box('carrousel', 'Carrousel opties', 'carrousel_options', 'page',/*show on 'pages'*/ 'normal', 'high');
    }
    
    //this will add a meta box with custom fields
    function carrousel_options ($post)
    { ?>
    <p>
        Description
    </p>
    <p id="field1_container">
        <label for="field1">Custom field 1</label>
        <br/>
        <input type="text" id="field1" name="field1" value="<?php echo get_post_meta($post->ID, 'field1', true) ?>" size="25" />
    </p>
    <p id="field2_container">
        <label for="field2">Custom field 2</label>
        <br/>
        <input type="text" id="field2" name="field2" value="<?php echo get_post_meta($post->ID, 'field2', true) ?>" size="25" />
    </p>
    
    <?php }
    
    //save the values of the meta box
    add_action( 'save_post', 'post_save' );
    function post_save($post_id)
    {
        // Check permissions
        if (isset ($_POST['post_type']) && 'carrousel' == $_POST['post_type'] && !current_user_can( 'edit_page', $post_id ))
        {
            return;
        }
    
        if (isset($_POST['field1'])) {
            $subtitle = $_POST['field1'];
            update_post_meta($post_id, 'field1', $subtitle);
        }
    
        if (isset($_POST['field2']))
        {
            $link = $_POST['field2'];
            update_post_meta($post_id, 'field2', $link);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using wordpress, I am pulling in a custom fields from specific posts to fill
I am using wordpress and use custom permalink structure: /%category%/%postname%/ My problem is that
I have a (Wordpress powered) website, and Google is indexing some of the sub-directories.
In wordpress I have a page set up to pull in a random post,
my Wordpress installation is placed in the directory named /wordpress. I have activated custom
Wordpress has a filter that automatically add paragraphs to posts. I can remove this
WordPress requires you give each blog post at least two fields: a title and
Wordpress 3.0 just came out and it was cited that one can make a
Wordpress checks periodically to make sure that the version of Wordpress being used is
Wordpress has a spam filtering plugin called Akismet that seems to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.