Yep, it’s not very common, but perfectly viable and nifty technique.
After the posts are retrieved in WP_Query
they are passed through the_posts
filter like this (where $this
is WP_Query
instance):
$this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) );
You just loop through array and assign the extra data you need to objects. Don’t forget to check the query for being right query you want to target.
Related Posts:
- How to get posts published between a date and today?
- How to show related posts by category
- Display all posts from specific categories on a page
- get comments and get posts in loop
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- How to display posts by current user/author in a custom page template?
- How to get previous 10 days post from a specific date – WP Query
- Query only Posts from Both of Two Category?
- Can’t show comments count per post outside loop
- WordPress get posts by date without query_posts
- How to Display Post View Count
- How would I get 1 latest post from a query for 5 posts?
- Can I set and show “important” post in my blog?
- get_next_post() and get_previous_post() return wrong posts
- How To Get Posts With A Specific Word
- How do I restart my loop with get_next_post()?
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Why is querying posts messing up my pages?
- Display all posts that were published before full post on single.php
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Post Loop Missing Most Recent Post
- Pagination with an array of post objects?
- How to order posts in an arbitrary order?
- Display Posts on Custom Page
- How to get posts from a current post’s month?
- Wrong post title displayed from loop
- While loop articles – if statement order
- Get the amount of posts on a current page
- Display Posts with template on a Page
- How to get posts published on the latest date?
- How to only publish posts with image in it
- Post Filtering by GET URL parameters
- How to give classname to post if post has no content?
- WP_Query: Show 10 posts in date order, first three random
- Display specific posts on home page
- Display 3 posts with different HTML markup using a loop
- Get posts from current category?
- How to merge the content of posts that have the same title?
- get posts, run a custom query, and join the results
- How to show post views shortcode data for each post on Posts List Page?
- WP_Query to get posts in a specific tag or has post_format
- Use special template for the first post in the loop
- How to get all posts in gallery post format template
- Modify WordPress loop after it has been run
- show latest authors blog post
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Adding a category at even positions on main loop with modified pagination
- How to get all post titles starting with numbers and symbols?
- How to inject a post within a loop
- Displaying posts on Homepage
- posts_per_page – Repeats only first posts ‘post__in’ array
- Word count for all posts of all authors
- View post with specific category id and name which I selected in the backend (drop-down option)
- How to show related posts by detecting the current category?
- Why does ‘get_the_ID’ work outside of the loop?
- WordPress Post Query Using Custom native MySQL like St_Distance_Sphere
- Get Posts Under Custom Taxonomy
- Print Current Post Index number within Loop
- Should we trust the post globals?
- Keep featured content post in homepage with original order
- How to get post content by calling ajax?
- Get the ID of the latest post
- WP_Query vs get_posts
- How set featured posts using checkbox in post edit screen?
- the_author() returns empty string
- get_children() Not Working with orderby Parameter
- Get first post from wp_query
- How to get all posts related to particular category name?
- get all posts ID from a category
- Do we still need to include a “if (have_posts())” in templates?
- WP_Query: Why is sticky post not first item in loop?
- How to return results of a get_posts() in explicitly defined order
- Query *only* sticky posts
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- Skip post in loop and mixin later
- How to show list of posts by author and category?
- Override the default number of posts to show for a single loop?
- How do I reorder (pop and push) items from WP_Query?
- How to know if get_posts() failed?
- post_name empty after wp_insert_post
- Reverse chronology of post listing
- Query posts distinct authors
- Why do I need to use The Loop on pages (inside page.php etc)?
- posts page – different lengths of excerpt
- Number of posts per page setting is not working?
- Retrieving 3 latest post from each of 5 different custom post types
- WordPress Number of Posts Not Changing With posts_per_page
- how to display full post with pagination on home page
- Count singular post views automatically
- Show the title of the latest post by author
- Looping through posts per category gives same posts for each category
- WordPress Posts Out Of Order after 3.1 Update
- Setting pagination for images attached to a post
- Find most recent authors
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Insert custom div between posts
- Display All Sticky Post Before Regular Post