• I was debugging a new theme I downloaded. The theme came with it’s own Tags page (tags.php). The issue was no posts were showing up on the page. So, I went about debugging it.

    At one point I thought I’d check to see if have_posts() actually said it “had posts”. so, right before the “if (have_posts())” I added

    echo have_posts();

    I didn’t know if I’d get a value displayed or not, but it was worth a try. Imagine my surprise when the next time the page was displayed, it had posts on it.

    Wanting to make sure I wasn’t seeing things, I then removed the echo statement and re-saved the page. On the next page refresh the posts were again missing.

    So, can someone explain to me what happened? How could adding the

    echo have_posts();

    right before the “if” have made the script suddenly work?

    And should I leave the echo there, or will it cause problems down the road? Should I remove it and figure out something else?

    Thanks

Viewing 1 replies (of 1 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Without knowing the code that’s around it, I can’t tell you why it changed things. have_posts() in itself does next to nothing.

Viewing 1 replies (of 1 total)
  • The topic ‘Why? (A Wordpres/logic/PHP question)’ is closed to new replies.