WordPress.org

Support

Support » Plugins and Hacks » Child theme code to call query_post after wp_home/wp_title

Child theme code to call query_post after wp_home/wp_title

  • Hello.

    I would really appreciate some help.

    I am using WordPress SEO by Yoast with the suffusion wordpress theme and I’ve noticed that when I add a query post on my website, the title displayed on my browser is always the title of the last post in the query post widget.

    I’ve found on the web that the way to solve this is to make sure that the call to wp_head or wp_title (not sure which one) has to come before the call to query_posts.

    I’m not familiar with coding and was wondering how I could achieve this with a child theme?

    As well, could these changes cause any potential problems.

    Thanks in advance for the help.

    P.S.
    I did not add <title><?php wp_title(”); ?></title> to my header.php but just checked the box to Force rewrite titles in the WordPress SEO plugin

Viewing 4 replies - 1 through 4 (of 4 total)
  • are you ending you query_posts loop with wp_reset_query(); ?

    http://codex.wordpress.org/Function_Reference/wp_reset_query

    Appreciate the reply.

    Just to clarify, the query posts are actually built-in widgets of the theme that I have added to my sidebars. I have not added any code.

    I don’t understand coding and have tried using your suggestion and some online tutorials to add this code in the suffusion child theme:

    <?php
    add_action(“after_setup_theme”, “suffu_scion_theme_setup”, 15);

    function suffu_scion_theme_setup() {
    wp_reset_query();
    }
    ?>

    This doesn’t work though. Would you have any other suggestions.

    Thanks.

    P.S. I have also changed the 15 to 1 but still nothing happens.

    In the suffusion-query-posts.php file, around line 182 you will see this:

    $ret .= "</ul>";

    Just before this line add:

    wp_reset_query();

    Works like a charm!

    By far the best and most versatile theme.

    Thank you very much Sayontan.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Child theme code to call query_post after wp_home/wp_title’ is closed to new replies.
Skip to toolbar