How select a specific query when setting offset?

If you only wish to effect the one, single query then just can pass the offset argument through the arguments array. $offset = 1; $ppp = 3; if ( $query->is_paged ) { $page_offset = $offset + ( ($query->query_vars[‘paged’]-1) * $ppp ); } blog_items = array( ‘post_type’=> ‘post’, ‘paged’ => $paged, ‘posts_per_page’=> $ppp, ‘status’ => ‘publish’, … Read more

Offset Page Loops and Pagination

I messed around with the code some more, and my particular issue actually ended up relating to the original if statement parameters. Changing the condition to check the home page for queries to if ( $query->is_home() && ! $query->is_main_query() ) { return; } and else { //This is the first page. Just use the offset… … Read more

Most commented / popular posts and offset

Here’s your code wrapped up in a plugin. The important thing is that it prepare()s the input, so the query is safe. You can define 2 arguments: Offset & Limit. Those are basically just the SQL LIMIT. If you don’t have any use for the plugin, just deactivate it, as it won’t do anything – … Read more

Get the index of post outside the loop

The problem of your code is that $wp_query is a global variable. Once the sidebar is loaded via a function (dynamic_sidebar) you need to globalize that variable before use. However, once you are in the single view the current_post is always 0. You have to run another query, loop it, and check the every post … Read more

Specific Loop For 2 Within Each

i use this code in my portfolio http://pocketapps.co/ <?php $args = array( //your argument code ); query_posts($args);?> <ul> <?php $ls=0; while ( have_posts() ) : the_post(); ?> <?php if($ls%2==0): echo ‘</li><li>’; endif; ?> <div class=”app”> //your code here </div> <?php $ls++; endwhile; wp_reset_query(); ?> </ul>

Related Posts loop – offset

Do you mean you want to display three blocks of four related posts, and flip between the three blocks using scrollable? If so, does the below help (not tested)? Assuming scrollable needs its content in separate divs, you could do something like this. It should produce a containing div with up to three divs inside, … Read more