0

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

2 Answers 2

5

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.

-1

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

1
  • 1
    Main template files are included in global scope, so global $post; is of no use here. Commented Apr 28, 2011 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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