[Solved] Insert html after certain amount of posts?

You could use the following and it should do exactly what you want by checking the value of $loop->current_post. <?php $loop = new WP_Query( array( ‘post_type’ => ‘work’,’posts_per_page’ => ‘-1’ ) ); ?> <ul id=”carousel”> <li> <ul class=”inner-items”> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php if( $loop->current_post && !($loop->current_post % 6) ) : … Read more

[Solved] Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

[Solved] When should you use WP_Query vs query_posts() vs get_posts()?

query_posts() is overly simplistic and a problematic way to modify the main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like … Read more