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?
- get_children() Not Working with orderby Parameter
- post_name empty after wp_insert_post
- Strange switch_to_blog() issue
- Multiple loops in same page, without duplicate content
- Different amount of posts on homepage than paged pages
- The correct way to call posts with ajax
- Get specific posts by ID in wordpress
- Automatically republish old posts
- Category Foreach keeps looping?
- Posts will not display on page-mypage.php
- How to make multiple sections in home pulling posts category wise?
- How to get posts and comments amount per hour, per year and per month?
- Conditionals if tags exist?
- Change all author links in Blog roll
- Random posts from a pool of posts
- Showing categories and subcategories with posts
- Conditional Tag for has post [closed]
- get_posts output always same post
- why the same code got different results when using query_posts in functions.php and index.php
- older blog posts not showing in new theme
- WordPress Query Posts From Category Post on Static Page
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- Cannot implement byline into posts container in single.php
- How to check if there are posts with the same tag
- WP_Query of Category Not Showing First Post
- How to add content above footer in posts from specific category
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Show posts from two specific category in WP_Query
- Permalink Short code showing unnecessary link text inside the loop
- REST API Working for GET but not for POST?
- Fill the exclude array() in get_posts()
- Double loop output
- post->ID displays the same ID number for every post
- How to correctly escape data
- Sort Events by Venue Title – Sort Post set by related post ids
- Post are not showing up
- Get posts by category or author
- How to make post button to a random post
- How to pass multiple checkbox values to wordpress query?
- How to get single post by one author?
- query_posts different amount of posts per page [duplicate]