• Holkan

    (@cubeinthebox)


    Hello there!

    I’m struggling with a template that, for some reason that I don’t know, it’s not getting any posts in it. I mean, I have a website with a lot of tags, in that site I have a tag.php file for the tag template. So far so good. But when i try to query the posts by doing the traditional if(have_posts()) while(have_posts()) the_post() … I don’d get any posts. It’s the same for every tag, even when they have more than 1000 posts assigned to them.

    When i print the global variable $wp_query I can see the object, but the post_count attribute says it doesn’t have any posts ([post_count] => 0)

    I’m not messing with pre_get_posts in functions at all, so i think it may be something else.

    Anyone has a clue about what may be happening or how can I troubleshot this issue?

    FYI
    This is happening in a custom theme.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Echo out the global $wp_query->request on your template for examination (it’s the SQL run for the page). There’s something in there that is preventing it from finding tagged posts. You may not need to know SQL very well to see the problem. If you see a nonsensical WHERE 1=0 it means the WP query parser couldn’t make sense of the HTML request for some reason.

Viewing 1 replies (of 1 total)
  • The topic ‘Why is main query broken in tag template?’ is closed to new replies.