WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My single.php file has the following code:

<?php // Set and display custom field
    $intro_image = get_post_meta($post->ID, 'Intro Image', true); ?>
    <div class="block-1">
        <img src="<?php echo $intro_image; ?>" alt="" />
    </div> <?php

The user will have to type Intro Image (once) in the 'Name' field in order to see it next time in the drop-down list. I think it would be better if the user can see 'Intro Image' right after installing my Wordpress theme (I feel that the user should select options that are available, not write them down themselves).

I'm not sure if what I'm saying make sense. But how to have those 'Names' available in the drop-down list before writing them?

share|improve this question
up vote 1 down vote accepted

your best option is to create a custom meta box with-in your theme and then the user will have it no matter if he typed it once before.

// Hook into WordPress
add_action( 'admin_init', 'add_custom_metabox' );
add_action( 'save_post', 'save_custom_intro_image' );

 * Add meta box
function add_custom_metabox() {
    add_meta_box( 'custom-metabox', __( 'Intro Image' ), 'intro_image_custom_metabox', 'post', 'side', 'high' );

 * Display the metabox
function intro_image_custom_metabox() {
    global $post;
    $introimage = get_post_meta( $post->ID, 'intro_image', true );
    <p><label for="intro_image">Intro Image:<br />
        <input id="siteurl" size="37" name="intro_image" value="<?php if( $introimage ) { echo $introimage; } ?>" /></label></p>

 * Process the custom metabox fields
function save_custom_intro_image( $post_id ) {
    global $post;   

    if( $_POST ) {
        update_post_meta( $post->ID, 'intro_image', $_POST['intro_image'] );

Hope This Helps

share|improve this answer
Yes, Thanks. I tried to do that. But in the tutorial I'm following they call them Custom Write Panels. Is it the same thing? (link: wefunction.com/2008/10/…) – janoChen Feb 17 '11 at 16:12
basically yes, but try this tutorial which i found very easy to follow deluxeblogtips.com/2010/04/… – Bainternet Feb 17 '11 at 16:29
Thanks! I will follow the tutorial (even if it is published using Blogger). – janoChen Feb 17 '11 at 16:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.