Strict Standards: Redefining already defined constructor for class bbdb in /home/themes/public_html/forums/bb-includes/db-mysql.php on line 12

Strict Standards: Declaration of BB_Walker_Blank::start_lvl() should be compatible with BB_Walker::start_lvl($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::end_lvl() should be compatible with BB_Walker::end_lvl($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::start_el() should be compatible with BB_Walker::start_el($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::end_el() should be compatible with BB_Walker::end_el($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127
page template returning incorrect title (fix included) « ThemeShaper Forums

ThemeShaper Forums » Thematic

[closed]

page template returning incorrect title (fix included)

(1 post)
  • Started 5 years ago by mpedrummer
  • This topic is not resolved

Tags:

  1. mpedrummer
    Member

    Hi all - thanks for the framework, it's been making a lot of things easier for me. I'm migrating a large website from an old wiki to WordPress, and we're using Thematic. Once it's available publicly, I'll be sure to share!

    Anyway, part of the site is documentation, which means pages - lots of pages. I discovered a bug in the page.php template, or more specifically, in the function thematic_doctitle(). In the case that is_page() is true, it generates the doctitle using single_post_title(). This is the problem.

    Here's the issue - with multiple posts with the same post_name in the wp_posts table, single_post_title() returns the name of the first one it finds. This is not necessarily the correct one. This only happens with pages, it appears that at an application level, WP enforces uniqueness on this column when the post_type is 'post'.

    In WP's code, the comment for single_post_title() indicates that it's not supposed to be used for pages. The function uses get_query_var('p') to attempt to determine the ID of the page/post. If that variable is not present (it's not) then it uses get_query_var('name') instead, which causes the incorrect behavior.

    I figured out a simple way to get the correct ID into the cache of query variables.

    In the page.php template of your child theme, replace this line:
    <?php get_header() ?>

    with

    <?php
    // Call the_post() first to let WP resolve things correctly
    the_post();
    // Insert the ID as a query var
    $wp_query->set( 'p', get_the_ID() );
    get_header();
    ?>

    And it works! This isn't a "fix" per se, more of a bandaid/workaround, but it corrects the behavior.

    Posted 5 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.


Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GA_Filter::spool_analytics() should not be called statically in /home/themes/public_html/forums/bb-includes/wp-functions.php on line 586

Strict Standards: Non-static method GA_Filter::spool_this() should not be called statically in /home/themes/public_html/forums/my-plugins/googleanalytics.php on line 183