Question

I'm a newbie Wordpress developer & I can't figure out how to get the options chosen in my Custom Meta Boxes to populate on my posts. For example, this is how my admin panel looks when creating new posts:

http://i.stack.imgur.com/9RGz8.jpg

To give you an example of my code for this section that is in my meta.php file... It's:

    //POST META BOXES
        'post'=> array(

            array(
                'name' => 'Home Type',
                'id' => PEXETO_META_PREFIX.'text',
                'type' => 'select',
                'options' => array( array( 'name'=>'1', 'id'=>'1' ),
                    array( 'name'=>'2', 'id'=>'2' ),
                    array( 'name'=>'3', 'id'=>'3' ),
                    array( 'name'=>'4', 'id'=>'4' ),
                    array( 'name'=>'5', 'id'=>'5' ) ),
                'desc' => '...'
            ),

            array(
                'name' => 'Listing Status',
                'id' => PEXETO_META_PREFIX.'text',
                'type' => 'select',
                'options' => array( array( 'name'=>'1', 'id'=>'1' ),
                    array( 'name'=>'2', 'id'=>'2' ),
                    array( 'name'=>'3', 'id'=>'3' ) ),
                'desc' => '...'
            ),

            array(
                'name' => 'Lot Size',
                'id' => PEXETO_META_PREFIX.'text',
                'type' => 'text',
                'desc' => '...'
            ),

What I'm trying to do is set it up so that each meta box will generate a two column row in my actual post. The left side would show the title of the box, and the right side would show the answer given by the user. An example of this is below:

http://i.stack.imgur.com/suJTq.jpg

Any help with this one would be greatly appreciated as I'm stuck...

Thanks.

Was it helpful?

Solution

You should look into get_post_meta()

Then something like this to echo those metas out in a table:

$metas = get_post_meta( get_the_ID() );
echo '<table>';
foreach( $metas as $key => $meta ) {
    printf('<tr><th>%s</th><td>%s</td></tr>',
    $key, $meta[0] );
}
echo '</table>';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top