Forums Forums Search Search Results for 'found_posts'

Viewing 4 results - 171 through 174 (of 174 total)
  • Author
    Search Results
  • #2788

    Ross
    Keymaster

    Hey Mark

    It seems that maybe there is some other custom query on your page which makes this count incorrect – for example if your theme runs its own query_posts or something similar on the page then the found_posts value may be reflecting this.

    You could try resetting the main query before you check found_posts however this may break something else in your page:

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

    Something like:

    <?php
    wp_reset_query();
    global $wp_query;
    $total_results = $wp_query->found_posts;
    ?>

    Basically it seems like your theme is overriding the default setting, or not resetting the main query once it has finished running its custom functions?

    Thanks

    #2728

    Anonymous
    Inactive
    function search_abovecontent() {
    ?>
    <div class="results">		<?php
    global $wp_query;
    $total_results = $wp_query->found_posts;
    ?></div>
    <?php }
    add_action('thematic_abovecontent','search_abovecontent',0);
    #2727

    Anonymous
    Inactive

    Hi Ross this does not seem to have worked for me. I am using Thematic as my theme and added a hook to put this above the content

    <div class="results">		<?php
    global $wp_query;
    $total_results = $wp_query->found_posts;
    ?></div>

    Any thoughts how I can implement it?
    Thanks in advance

    #2258

    Ross
    Keymaster

    Hey Luca

    Try this in your template:

    <?php
    global $wp_query;
    $total_results = $wp_query->found_posts;
    ?>

    (Taken from: http://codex.wordpress.org/Creating_a_Search_Page)

    Let me know if that works!

Viewing 4 results - 171 through 174 (of 174 total)