WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I fetch external data like this, but I also added the_post();

while($slice = mysql_fetch_assoc($result)){
    rest of my stuff

I need a hook to tell me if the_post() returns true, something like this:

while($slice = mysql_fetch_assoc($result)){
    if(the post returs true){ do something;
    else { rest of my stuff }

Any ideas?

share|improve this question
what are you trying to determine exactly? the_post doesn't return anything. – Milo Aug 3 '12 at 15:37

if you use the native wp_query to select posts instead of custom sql queries you can check against the have_posts() method of wp_query

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.