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

Popular posts from this blog

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -