Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created an options page to ad gigs as custom posts in my theme. This is in my functions.php

    $config = array(
    'id' => 'gigs-info',
    'title' => 'Gig Info',
    'pages' => array('gig'),
    'context' => 'normal', 
    'priority' => 'high', 
    'fields' => array(), 
    'local_images' => false,
    'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
$my_meta = new AT_Meta_Box($config);

//Add fields to your meta box
$my_meta->addText($prefix.'where',array('name'=> 'Where is the Gig '));
$my_meta->addDate($prefix.'when',array('name'=> 'When is the Gig '));
$my_meta->addTime($prefix.'start_time',array('name'=> 'When Does it Start '));
$my_meta->addTime($prefix.'end_time',array('name'=> 'When Does it End '));
$my_meta->addText($prefix.'with_who',array('name'=> 'With Who is the Gig '));
$my_meta->addTextarea($prefix.'words',array('name'=> 'A few words on the gig '));
$my_meta->Finish();
}

How do I display the content of these various fields in my index.php?

I currently have this...

       <?php
$args2 = array
    (
        'post_type' => 'gig',
        'numberposts' => -1
    );
    $prefix = "_gig";
    $gigs = get_post($args2);
 foreach ($gigs as $gig)
 {
echo get_post_meta($gig->ID, $prefix.'where', true);
  }
?>
share|improve this question

1 Answer 1

I think you want to look into using get_post_meta and then display it with that. Here it is on the Codex: http://codex.wordpress.org/Function_Reference/get_post_meta

You can look at this example:

<?php
echo get_post_meta($post->ID, $prefix.'where', true);
?>

That should get you what you need if I understand the question correctly.

share|improve this answer
    
hmmm it's not returning anything –  marctain Feb 29 '12 at 7:06
    
Before you do the echo for the get_post_meta just echo out something like echo 'the gig id is '.$gig->ID; to make sure that it is getting an id to use and also check your wp_postmeta table to make sure you have values in the table –  user1048676 Feb 29 '12 at 7:22

Your Answer

 
discard

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.