can I run new WP_Query inside the Loop with no affects to the Loop? (wordpress) -


The brake function is working fine but I need to run it inside the loop. If this is done then the post content is actually taken from the last post of my WP_Query. Not what you should look like

Is there a way to run my query and leave unused ?

Function Recent_post_b_authorer () {echo '& lt; Div class = "recent_post_by_author" & gt; '; $ My_query = New WP_Query ('author_name = Radek and showposts = 2'); While ($ my_query- & gt; is_pause ()): $ my_query- & gt; The_post (); ? & Gt; & Lt; A href = "& lt ;? php the_permalink ()? & Gt;" Title = "& lt ;? php the_title () ;? & gt;" & Gt; & Lt ;? Php the_title (); ? & Gt; & Lt; / A & gt; & Lt; BR & gt; & Lt ;? Php timeline; Echo & lt; / Div & gt; '; }

It's up to you to call after you have your separate looping WP_Query Example

The problem is visible because WordPress uses a global $ post variable whenever that code

() is any of the WP_Query The object is called on. When you call it to your 2-post-reddec query, it loses the track of the original WP_Query object.


Comments