You can filter any WP query using pre_get_posts()
. The (sometimes) tricky part is that it is run against all queries of WP so you need to pinpoint your query using WP conditionals (is_admin()
, is_page()
, is_archive()
, etc… ).
You’ll find a few useful examples on that page, too.
Related Posts:
- WP_Query vs get_posts
- get_template_part in for loop
- How-to exclude terms from the main query the most performant way?
- get_posts() seemingly ignoring post_type
- Get posts for last working week in WP_Query
- Conflict with get_posts and the_content
- Best choice for multiple loop in page?
- get_posts output always same post
- Function using get_posts() with tax_query not working when called from functions.php
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Populate select list with meta values from all posts of a Custom Post Type
- Related posts queries
- Ordering Posts by parent category, name ascending
- Both WP_Query and get_posts returning 1 post
- tax_query not working properly with get_posts
- Some doubts about how the main query and the custom query works in this custom theme?
- Using a custom WP_Query with get_template_part loop
- Loop within a loop?
- How to list some posts first in the loop based on post id
- Using get_posts vs. WP_Query
- Display posts the match taxonomy term linked from wp_list_categoies?
- WordPress Custom Query to show posts from last x years
- How to order posts tag by tag?
- Merging a complex query with post_rewind and splitting posts into two columns
- Use post__in and post__not_in together?
- Pagination Not working on Home Page with 2 Query
- meta_query not working properly
- Exclude post on loop by multiple meta key value
- Get all posts without tags
- How to find out what “Blog pages show at most” is set to [duplicate]
- Sort by meta key on archive page
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Query sticky posts with thumbnails
- Show all parents and children in custom post type in right order
- Why is this coming back as null? Thats wrong. There is one post
- Ignore post by meta value in the main query
- How to retrieve current page WP_Query arguments?
- How do you Query posts with nothing in common?
- How to limit WP_Query to one result on the loop?
- if/else on custom query gives 200 OK when condition not met?
- Multiple Loops Inside a Function
- Random loop with code to prevent duplicate output returns no output at all from time to time
- How to use offset in WP_Query
- Multiple loops without repeating content
- Can I set my WP_Query to be a Main Query?
- Filtering posts from different categories into different section by doing WP_Query only once
- get_post_meta slowing down my page load (in a plugin)
- How to get list of posts from permalinks?
- Custom taxonomy.php not working
- different for loop if screen resolution < 1000px
- Transient api Caches confused
- Get all posts which was posted on X Days WordPress
- get_posts always returning the same number of posts = 5
- sort and display posts by custom field (wp-query and the loop))
- Get posts that do not have the same tags as current
- Exclude a Woocommerce product from WP_Query
- WP_QUERY wrong ammount of posts
- inserting content of 1 Post to in another with a template hierarchy
- get_posts custom field
- How to apply a function to a metadata value before launch a WP Query?
- Expecting statement error from php loop using ACF plugin
- Woocommerce: order posts by meta key
- How do I sort this custom list of sticky posts
- Query only displays one page_id
- Pagination for custom loop on custom page template is not displaying anything
- Filtering by multiple conditions in the loop
- Get posts with no tags?
- get_posts query matches too many results
- wp-query, pull children of parent page
- I am officially missing something about transient posts
- How do I get the content of a custom instance of WP_Query?
- How to query for a page, get data, then query for child pages of that page
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- Can I alter the main loop to ‘orderby’ a custom callback?
- Show a message if there are no active posts in category
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- Problem with my loops
- display the children of the post using the current page as the main parent
- Display 3 levels of categories on page
- Paging works correctly on local version, but not live?
- Custom post type loop error: Trying to get property of non-object
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Getting the last X posts, but in ascending order of time
- Display three sequential posts on each page load, without repeating previous
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- How to make a wordpress loop file that displays posts based on certain conditions
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Issue in If else condition [closed]
- Pagination not working with WP_QUERY
- How do I display posts with specific value in a custom field into my loop?
- Order by multiple meta keys on wordpress
- wp_query pagination links producing 404
- Display First posts without the default featured image
- Pagination problem with multiple loops on the same page
- Can’t seem to get an else statement correct? [closed]
- Output ACF field dynamicaly within a taxonomy loop [closed]
- How do I split a large query with a semi-expensive function included into multiple smaller queries
- How to replecate the _fields parameter in custom REST api endpoint
- Show number of posts AND number on current page (cannot make it work)