the_post() conflict in wordpress script -
i have code similar this:
while (have_posts()) : the_post(); .... more code ... $my_query = new wp_query($args); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); .... other code ..
the question how avoid conflict the_post()
? because first while loop
i'm accessing posts
, second while other posts. , website display info second while, should display info of posts first while. think confusing posts...
you can use wp_reset_query()
function
while (have_posts()) : the_post(); .... more code ... wp_reset_query(); $my_query = new wp_query($args); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); .... other code ..
here reference manual wp_reset_query()
Comments
Post a Comment