WordPress.org

Ready to get started?Download WordPress

Forums

"the_meta" call - changes in v3.0.1?? (2 posts)

  1. tallhat
    Member
    Posted 3 years ago #

    i've just upgraded a site from 2.9x to 3.0.1 and all's fine except for a bit of custom code which should display a custom field value as a title in a sidebar (this is via a PHP widget)

    the code is

    <div class="sidebar-title">
    <?php
    if(is_home()) { $sbtitle=get_post_meta(19, 'sidebar_title'); echo '<h1>'.$sbtitle[0].'</h1>';} else echo the_meta();?>
    </div>

    the title is still working on the 'home' page but not on all other pages (i.e. it seems to no longer like the call to 'echo the_meta()'. nothing else has changed. any suggestions of how to get this working again? there's no error message, just nothing displaying. i've tried get_post_meta($post_id, 'sidebar_title') instead but no luck here either. it only seems to work if specifying the post id directly (as in the '19' example above).

  2. tallhat
    Member
    Posted 3 years ago #

    ah, this worked

    global $post;
    echo get_post_meta($post->ID, 'sidebar_title', true);

    seems the 'global $post' bit is crucial and possibly a new version 3
    requirement??

Topic Closed

This topic has been closed to new replies.

About this Topic