You can use the the_posts filter to loop through the results before they get returned.
Proof of concept:
function test_the_posts($a) {
var_dump($a); die;
}
add_action('the_posts','test_the_posts');
I am fairly certain (though I haven’t tested it) that you could pretty easily break pagination and probably other things by fiddling with that, so be careful.
Related Posts:
- How to fix pagination for custom loops?
- Remove the Homepage Query
- pre_get_posts with get_posts
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- WordPress Number of Posts Not Changing With posts_per_page
- Insert/sticky specific post into Loop at specific location
- Transient not working for custom loops
- post loop causes wp_users and wp_usermeta DB queries for each users
- get_the_foo() in the loop – does it perform another query?
- If No Search Results, Show Posts from Alternate Search Query
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- How to Loop within a Loop (Display Children and then Grandchildren)
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Two loops by pre_get_post on same page
- Loop posts only excluding first post
- Loop after page content
- A loop with all articles with certain text strings in tags
- Display most viewed post from last 30 days is not working correctly
- Query posts if meta key starts with
- 3 Posts in Loop, Show Stickies First
- How to go about combining dropdowns / filter queries?
- Query reset problem or flawed code to enable custom post type query
- Query last updated posts (posts updated in the last 24 hours)
- Conditional query that displays on Woo product attribute pages
- How do I use AJAX Query in my posts loop?
- woocommerce get_price_html not pulling in correct price
- Make blog page show 10 on first page, 9 on every other page
- Exclude posts from main loop based on meta value
- Alter query using pre_get_posts() if meta_key is present
- How to fix pagination for custom loops?
- pre_get_posts for two loops on same page
- Sanitize Custom Field Value in Meta Query
- How can I paginate this?
- How to display posts by vote count and if no value continue with latest posts with no votes?
- How to fix pagination for custom loops?
- Modify the main loop to display current month / year
- Split wordpress loop to multiple layouts
- Making a query to the DB using same parameters of loop
- Loop inside query
- Change post order by meta key, per post basis
- get_delete_post_link() inside Loop stubbornly returns nothing
- loop inside the foreach
- Query posts only with actual text content (not including shortcode or images)
- Exclude posts based on an array
- Query post & loop problem.
- Loops for cat links not looping for wordpress site
- How do I set the Stewart Search Template to return only published posts in the result
- Trying to get all links in my posts
- Custom Query with Sticky Posts
- Build a Page which shows the Oldest Post with specific Custom Field Value
- Exclude Posts Using Meta Query and User Meta
- Query posts and display all dates in repeater field in chronological order
- How to fix pagination for custom loops?
- Get featured image outside the loop using foreach
- Alternative layout the loop
- Show posts by tags excluding current post
- Strange problem with wp_get_attachment_image_src database (db) query count
- pre_get_posts main_query not displaying after applying tax_query filters
- Next 10 posts data of currently viewing post in blog page
- How to fix pagination for custom loops?
- Query counting excluded category on paged loop
- How to fix pagination for custom loops?
- How to fix pagination for custom loops?
- Combine Query and Select Database to create directory loop
- WordPress loop: Display if posts exist
- wordpress showing all posts instead of date range
- Multiple loop with pagination in same page
- How to use orderby on meta_value when using Pods custom database table storage
- Query Loop Block: possible to restrict just child pages?
- Use Base-URL with Query-Loop
- Using Query Loop Block to list all posts under each category
- is_category() in pre_get_posts strange error
- How to return loop contents
- Add Custom Post Type to Current Query
- How to exclude latest x posts from a paginated query?
- How to get the first image gallery of a product in woocommerce in a loop
- the_title(); works in a page template, outside the loop. Why?
- Add 20yrs to post date, and then query
- Displaying terms based on loop posts?
- Custom post type appearing within the previous one on archive.php
- How do I go about looping through a advanced custom field on a particular page inside of another page
- Using Javascript for Looped Content
- Variable not being passed into WordPress loop
- How to ignore posts in pre_get_posts?
- WP Loop. If featured image is a panorama (3:1 ratio) execute some code
- Include future posts in tags and in search
- current-user_can not working in loop
- Show terms in archive page
- Multiple loops for plugin
- How to get all multi-select user meta values and add them to an array?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Excerpt isn’t working or am I missing something?
- Can I temporarily disable global $post?
- Infinite Loop after Genesis Theme Upgrade
- WordPress loop only displays 5 articles max?
- Pass WP post content to a jQuery plugin (Fancybox)
- Showposts doesn’t show the number of posts indicated
- Main loop querying current template’s info only in custom category archive pages, not my posts
- How to make FSE’s query loop to order by comments number?