WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Search Results Problem (5 posts)

  1. ghostpool
    Member
    Posted 4 years ago #

    I'm in the middle of creating a new theme and after testing my search results it seems one of the results is always excluded. So for example the $wp_query->found_posts will say I have 14 search results but only 13 are shown, or if I have 1 result 0 are shown. Switching back to the default theme fixes the issue so it's definitely something in my theme causing it. I've removed everything from the theme bit by bit to try and find the cause but nothing fixes it. I'm pretty sure I've closed all queries and/or reset queries and the search has no custom query.

    Has anyone come across such an issue before and have any suggestions?

  2. ghostpool
    Member
    Posted 4 years ago #

    To add to my previous post, unsurprisingly it is all loops that are missing one post, the latest post. I just can't find the source of the problem.

  3. Mark / t31os
    Moderator
    Posted 4 years ago #

    Maybe something in the functions.php filtering/excluding from queries?

  4. ghostpool
    Member
    Posted 4 years ago #

    I'm going to go over the functions.php file again. I really removed everything from it last time and the problem still occurred, but maybe I missed something. The queries on the index page work fine, but all other queries e.g. categories, search results etc. are affected. It's as if an offset=1 hasn't been closed and affecting everything.

  5. ghostpool
    Member
    Posted 4 years ago #

    The great mystery is solved.

    Notice something:

    <?php if(have_posts()) : the_post(); while(have_posts()) : the_post(); ?>

    For some reason I added an extra the_post. :S

Topic Closed

This topic has been closed to new replies.

About this Topic