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 know if get_posts() failed?
- Display Latest Post from all Categories
- custom wordpress post loop – hide iframe content
- wp_tag_cloud() and the_taxonomies() work but not the_tag()
- previewing my posts on static page?
- Show all posts in sidebar in single.php
- Split WordPress Latest Posts in Multiple Columns and Rows with one single loop [closed]
- Avoid duplicate post from same Taxonomy
- Insert Content In Between Post Feed
- Get Posts Under Custom Taxonomy
- wp_query random post
- How do I stop the loop from repeating in my category template?
- How many posts does the loop return?
- Posts loop displaying the same post data
- Possible to alternate between two loops
- Second get_permalink inside loop points to wrong URL
- Counter is skipping post when I still want it visible [closed]
- Use Click Image to Play Youtube Video in a WordPress Loop
- The_excerpt() doesn’t parse – how to change that?
- Trying to edit archive.php to only show post extract, with featured image
- Extracting relevant tags associated with that particular single post only
- wp_query with ajax
- Custom Articles page only showing a limited number of posts per page
- Custom posts listing widget always returns 1 extra result
- Show posts by quarter
- Get x recent posts by author?
- Get postlist for each category using query_posts?
- Cant’ Grab WordPress Built-in Posts Through Loop
- Pagination for normal (standard) posts on a page with a custom loop?
- Current post categories and subcatecories outside of the loop
- “read more” redirects to the wrong page
- Count singular post views automatically
- Loop through all posts showing duplicates
- List Authors For Current Category
- Display the latest post from some selected authors
- get “read more” with custom DB query like you would with WP Query
- How to use extract shortcode in loop?
- Where are my posts linked to? I keep getting a Not Found Error, and I have no single.php page
- WordPress posts loop pagination – first page return 125 posts instead of 10 and the rest return 10
- The post order is different for logged-in and non-logged-in users? [closed]
- How do I show the post title if an advanced custom field hasn’t been used?
- append $_GET parameters to post
- CSS code for “inserting a custom post divider” after each post
- Sort Posts Alphabetically Based on Specific Category (Divi)