my site has a sidebar that displays latest post headlines, by querying x number of posts and linking to each article’s permalink with its title as anchor text. It works fine 90% of the time, but there are so far two pages I’ve noticed it refuses to cooperate on:
1. the search results page. It works fine if a search returns results, but if a search finds no matches, everything in my sidebar that pertains to the loop will be completely nonexistent. No idea why this is.
2. the 404 page. Same exact code as every other page, more or less, but the loop does not want to appear on it.
i have attempted to insert a “$post = $wp_query->post;” in the areas where the loop will not work, but it doesn’t help. I am already using a “$sidebarposts = new WP_Query(”);” on my sidebar, and it works fine on other pages that contain multiple loops, but this doesn’t seem to solve my problem either as far as these two pages are concerned.
if anyone has any insight as to how I can correct this, I would greatly appreciate it. Thank you 🙂
- The topic ‘unable to query posts on certain pages’ is closed to new replies.