Articles of offsets

How to calculate post index when using offset in custom query

Not sure if I’m using the proper terminology in my title so feel free to correct. Say I have a custom post type called colors with say 40 posts that are in the default order in single_colors.php I have: $my_query = new WP_Query( array( ‘post_type’ => ‘colors’, ‘posts_per_page’ => 5, ‘offset’ => 2 ); if […]

WP_Query – Adding “offset” posts to the end of the loop

I’m trying to create two queries. In the first query, I will, for example, display 6 posts, in a given order. In the second query, I want to display the same 6 posts, but “offset” the first 3 and then have those same 3 appear at the end. For example, Query #1 would return: 1 […]

Stomping WP_Query in author archive to facilitate pagination with custom queries

I am using get_posts and get_comments to build several loops on the page, at which I am having some issues in pagination. I have the global posts per page option (Settings > Reading) set to 10, and this seems to vary the problem. As of now, I can easily get to Page 2 – http://dev.ashfame.com/author/ashfame/page/2/, […]

Loop Offset for tag based “Related Posts”

As I’m using the jQuery Tool “Scrollable” for my Related Posts section (see example here), I was wondering how I can implement an offset so that in the first loop it’ll show the first 4 posts, then the next 4 related posts etc. I’m thinking about creating 3 loops like that right now, displaying the […]

Get post offset/posts page offset in single post page (outside the loop)

I would like to know how I could get the offset of a custom post or its page, outside the get_posts loop. I developed an external web application which connects to the wordpress blog with JSON API plugin, and show a given posts page using an AJAX request like : ?json=get_posts&orderby=date&order=desc&count=x&page=n (This will return the […]

Creating two loops based on different logic

I’m trying to figure out the best way to go about this and I have part of my solution, but I can’t figure out all of it. My ultimate goal is within a certain page template, to show the newest post from a CPT of a particular taxonomy, this seems to be the easiest and […]

How do I rewrite this loop as a new WP_Query style-loop?

How do I rewrite the if (have_posts()) : … while (have_posts()) : the_post(); style WordPress loop below as a new_query style-loop using <?php $the_query = new WP_Query();? ( As shown in http://codex.wordpress.org/Class_Reference/WP_Query ) The current loop below alternates post classes to display a grid of posts two posts wide (see image below). But I need […]

WP_Query with offset and 'orderby' => 'rand', offset not working

I have the following situation: on my index.php I am showing the most recent 20 posts using WP_Query(). On the same page in another section I would like to display 3 more random posts from the archive that are not among the 20 most recent. My code (the second WP_Query): $archive_random_args = array( ‘post_type’ => […]

WP_Query offset argument does not work

I want to display all posts starting from a certain offset, my query is: WP_Query( array( ‘posts_per_page’ => -1, ‘offset’ => 20, ‘cat’ => 5, ) ); This query shows all posts without starting from the offset value. Whys is that?

Comments offset

I need to display comments starting from the second, omitting the first. With posts I did it using “offset” but I can’t find anything similar for comments. Since I’m using threaded comments, must start from the second comment that is not a child (only parent comments). I’m using wp_list_comments with a callback. EDIT2: this is […]