WordPress.org

Support

Support » Themes and Templates » Meta Box.. Why Isn't This working?

Meta Box.. Why Isn't This working?

Viewing 7 replies - 1 through 7 (of 7 total)
  • here is a link to what i ended up with:
    http://pastebin.com/0JR3Rnj7

    and this is what i have to print the content of the input in the footer:
    <?php echo get_post_meta($post->ID, 'smashing-post-class', true); ?>

    any ideas?

    Hi newyotkcity,

    Please take a quick look at this site.
    http://www.farinspace.com/wpalchemy-metabox/

    I used to hand code all my metaboxes like that tutorial shows you but I haven’t had to write so much code since I found that class which makes this so much easier.

    @newyorkcity, if you put var_dump($post->ID) just before your echo do you get the correct post ID?

    Hi newyorkcity,

    You are using the $post global in the footer?

    Is that the post footer or the template footer, inside or outside the loop?

    Outside the loop!

    <?php if( is_post() ) : ?>
    <?php global $post; ?>
    <?php echo get_post_meta($post->ID, 'smashing-post-class', true); ?>
    <?php endif; ?>

    Inside the loop!

    <?php echo get_post_meta( get_the_ID() , 'smashing-post-class', true); ?>

    HTH

    David

    @s_ha_dum adding var_dump($post->ID) seems to make the footer.php disappear for some reason..

    @digital Raindrops Yea I guess it would be outside the loop! I forgot about the loop. Here is the very bottom of my footer.php:

    <?php if( is_post() ) : ?>
    <?php global $post; ?>
    <?php echo get_post_meta($post->ID, 'smashing-post-class', true); ?>
    <?php endif; ?>
    </body>
    </html>

    I checked for the info that should be posted right before the footer but I don’t see anything.. I’m on 3.3 right now since I have been having problems with 3.4 on some other themes

    @s_ha_dum adding var_dump($post->ID) seems to make the footer.php disappear for some reason.

    That is PHP code so it does need to be done with correct syntax, and needs to be inside opening and closing PHP tags. I sort of assumed that part. Sorry.

    <php var_dump($post->ID); ?>

    And, yes, it will make a mess of layout but it will also tell you whether or not you have the post ID that you need. Without it, this won’t work.

    Hi,
    Try this, it will output only on the footer on a page or single post, it will output all the meta data values in an array tree!
    Example:

    <?php
    if( is_singular() ) :
    	global $post;
    	$post_meta = array();
    	$post_meta = get_post_meta( $post->ID, false );
    	var_dump($post_meta);
    endif;
    ?>

    Add it inside the page tag!

    </div><!-- #page -->
    
    <?php wp_footer(); ?>
    
    </body>
    </html>

    HTH

    David

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Meta Box.. Why Isn't This working?’ is closed to new replies.