First of all,while( have_posts()):
should be while( $ml_featured->have_posts()):
And secondly, in your pre_get_posts
callback you check:
false == $query->query_vars['suppress_filters']
But this returns true for every WP_Query
query and any get_posts
query where ‘supress_filters’ is explicitly set to false. If you want to check if the query is the ‘main’ query (i.e. query associated with the global $wp_query
), you can use:
$query->is_main_query();
(see documentation here). This returns true if $query
is the main query and false otherwise. This function was introduced in 3.3. Before 3.3 you can probably check (untested):
global $wp_the_query;
if($query === $wp_the_query){
//is main query
}else{
// is not main query
}
Alternatively (but preferably use the methods above), to alter the main query only:
global $wp_query;
$wp_query->set( 'post_type', array( 'wod', 'attachment' ) );
Related Posts:
- Display all posts in a custom post type, grouped by a custom taxonomy
- Query by post title
- Get post with multiple meta keys and value
- Get posts for custom post type with WP_Query
- WP_Query() show posts that end later than today
- How to check if a WP_Query has data
- Sorting a query by custom field date
- Number of pages – multiple (custom) post types
- Enforcing canonical URLs with multiple custom post types
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Retrieving 3 latest post from each of 5 different custom post types
- Get latest 4 post on a custom post filtered by category
- how to group custom post type posts by custom taxonomy terms
- How to sort CPT by custom meta value (date), and return posts month by month
- Wp-query causing problems with the_content();
- wp_query and comment_parent – select only posts with top level comments
- Comparing timestamps in meta query doesn’t work
- Include both default and Custom Post Type in query modified inside pre_get_posts
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- List all custom post type posts from a given category?
- Exclude current post when getting related post on custom post type and taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Ordering Custom Post Types with WP_Query
- Filter posts with meta_query NOT IN where value has multiple values
- How to query different post types in specific order?
- Loop on front-page.php
- Querying Term Posts in Loop
- is_main_query() not working for WP REST API
- Can’t get order_by meta_value_num to work properly
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Loop through Custom Post Type, and then show children within each iteration
- orderby in custom WP Query does not work
- Unable to retrieve any posts of CPT in wp-admin
- How to make sure content doesn’t display if selection is empty
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Creating a navigation menu of all posts of a custom post type and their children posts?
- Wp_query: sort by PHP variable
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Crafting WP_Query array, sort by date
- forming WP_Query for posts of all post types but from specific categories
- How can I get the number of custom post type posts that have a specific attachment image set?
- Including metaboxes from custom post types in global search — continued
- Custom Widget WP_Query problem
- Why is my WP Query not returning first result’s post meta?
- Different Limit number of post on different archive page
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- WP_Query Custom Post Type if Category ID Equals
- Custom post types and ‘new WP_Query’
- Using page slug in wp_query
- Custom taxonomy wp_query woes.
- Trouble with pagination
- Select2 AJAX and WP Query Returns ALL and does not filter
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Returning a custom content types with meta values
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- List categories, subcategories and posts from custom taxonomy and custom post type
- Custom Post type loop with ACF not displaying properly
- Sort results without WP_QUERY?
- How to query Posts from a custom post type which contains a custom taxonomy?
- Searching post types
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- wp_query not returning my custom post
- filter the_content, custom post type, and wp_query
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Get_the_term_list inexplicably adds values in foreach
- Single parent post lists child posts with pagination
- wp_query can’t get max_num_pages in custom post type
- Custom Form / Search with Custom Post Type Data
- Get next and prev item from custom WP_Query and Custom Post Type
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Query to show post current day
- Using ACF values in nested WP queries for CPT with date values in the past
- WP_Query: how to search tags in addition to a custom post type?
- Pagination Not Working When Used With WP_Query() `offset` Property
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- Help understand and create a loop with WP_query
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- WP_Query for custom taxonomies showing posts from non-specified terms?
- how to display new private message to users?
- Make pagination work as a carousel (custom query)
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- Search result based on URL
- subtracting the current post form then whole loop, which is generating all CPT titles
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Loop carousel slider in wordpress
- Manually build WP_Query
- Loop with Custom Post Type and Taxonomies
- New WP_Query not isolating custom post types on front-page template
- 404 on Pages for Custom Post Type & Query_Posts
- Pagination not working on homepage
- How to query custom post then display sections by meta value
- Using tax_query to get single post per category
- Show Posts in Vertical Tabs with Scrollbar
- How to manage wordpress knowledge base/wiki/posts collections
- Is it possible to make is_category() recursive?
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- How can I show posts with the same tag?
- Load posts via AJAX without draft status