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.

For some reason this custom field is not being shown in the page.

This is the template file:

<?php

/**
 * Template Name: bbPress - Topics (Newest)
 *
 * @package bbPress
 * @subpackage Theme
 */

?>

<?php get_header(); ?>

        <div id="container">
            <div id="content" role="main">

                <?php do_action( 'bbp_template_notices' ); ?>

                <?php while ( have_posts() ) : the_post(); ?>

                    <div id="topics-front" class="bbp-topics-front">
                        <div class="entry-content">

                            <div id="page-intro">
                                <?php the_content(); ?>
                            </div>

                            <?php get_template_part( 'loop', 'bbp_topics' ); ?>

                        </div>
                    </div><!-- #topics-front -->

                <?php endwhile; ?>

                <?php if ( get_post_meta($post->ID, 'note', true) ) : ?>
                    <div id="note">
                        <p><?php echo get_post_meta($post->ID, 'note', true); ?><p/>
                    </div>
                <?php endif; ?>

            </div><!-- #content -->
        </div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

As you can see everything is set:

enter image description here

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

You're doing it outside of The Loop there, so $post is undefined at that point. Put it above the endwhile and it should work.

share|improve this answer
add comment

I have a similar situation and the global $post solution do the trick. :)

share|improve this answer
1  
Main template files are included in global scope, so global $post; is of no use here. –  John P Bloch Apr 28 '11 at 19:42
add comment

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.