WP_Query
does not accept a comma delimited string for the post_type
argument, it must be one of either a string
(for one post_type
) or an array
(for one-or-more post_type
).
$args = array(
'post_type' => 'post'
);
$query = new WP_Query($args);
OR
$args = array(
'post_type' =>
array(
'post'
)
);
$query = new WP_Query($args);
OR
$args = array(
'post_type' =>
array(
'post',
'page',
'movie',
'book'
)
);
$query = new WP_Query($args);
Useful reading:
Related Posts:
- When to use WP_query(), query_posts() and pre_get_posts
- How to get an array of post data from wp_query result?
- WordPress Pagination Not Working – Always Showing First Pages Content
- Whats the difference between post_limits and pre_get_posts?
- WP query taxonomy input differs to output?
- Query WooCommerce orders where meta data does not exist
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- What exactly does the ‘s’ parameter search for in WP queries?
- WP_Query min and max values
- post_type is ignored by WP_Query when ‘tag’ argument is included
- get_posts not finding argument: post_name
- get query’s query string
- Show only oldest post by author
- assign 2 $args to one wp_query
- WP_Query OR clause for tax_query and keywords
- Calling a custom excerpt function in a local loop
- Dynamically Override Fancy Title – Part II
- Transient pagination not working properly
- How to run query inside a class with namespace?
- Which filter/action hook gets triggered after a query has been performed?
- Modify existing query and change order of posts
- Why query_vars get altered in WP_Query Object?
- Why does the_content not work like others for a set post id?
- pre_get_posts filter meta_query without conflicting existing meta_query
- How would I format a query that depends on post parent taxonomy
- Minimising Database Queries when using Advanced Custom Fields
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- Creating a custom search for a specific post type
- How to add post_distinct filter to WP_Comment_Query?
- WP_Query Group by Author and Order each group DESC
- List only posts from specific category on category page
- Most popular post for last 7 days
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- How to avoid wp_query returning the same post I’m on in results?
- Query multiple meta values
- Why isn’t my multiple orderby working?
- WordPress Loop and $post
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- WP_Query tax query part of slug
- WP_Query ignoring tax_query when is_singular
- WP_Query() order by post content lenght?
- Query posts without meta preload
- How to implement a new row_count method in WordPress?
- Excluding pages in WP_query using ACF
- reset to main loop doesnt work
- Applying posts_clauses filter to specific queries only
- Shortcode for latest -not expired- posts
- WP_Query : Search and Filter Using custom field AND/OR custom taxonomy
- Query all posts if multiple meta key don’t exist
- meta_compare not comparing whole integer
- WP_Query – Object manipulation vs WordPress functions
- WP_Query with rewind_posts creates duplicate titles
- Transients with dynamic WP_Query
- How to remove the most recent post from $the_query
- How do I turn these values from MYSQL into an array
- Use Ajax To filter posts?
- Selecting posts with a given meta value for a meta key
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- Posts Query | Query to only show sub categories
- pre_get_posts – editing query, tax_query
- Check if a post has term inside loop
- Display all posts in a custom post type, grouped by a custom taxonomy. How to sort the posts alphabetically and the terms by ID?
- How to Order By Two Custom Fields?
- Display specific page (that is child) content on parent page
- Hacking ‘posts_per_page’ in WP_Query
- WP_query problem -spurious results
- Avoid duplicate while merging two query post
- ajax wp_query conditional tags not working
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- Query outputting YouTube url rather than embedded video
- max_num_pages says 4, yet I am only able to navigate to the third page
- Execute PHP function inside the admin area
- wp list pages using meta box value
- get_var is neither a string, integer, or array …?
- paginate_links appearing on page but it doesn’t actually paginate – pagination on a static page with a dynamic `post_type` argument on a static page
- Sort custom post by custom field if none order by latest release
- Form checkbox value going to dynamic URL
- show most viewed post
- wp query search multi terms
- How to get top rated posts using wp query?
- Unusual high query of user meta data
- Woocommerce featured products query no longer working
- add action for wordpress query at a specific position
- How to query wordpress with array of meta_values?
- Updating an intensive wp_query result once daily
- Custom WP_query and integrating into theme file
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- Get newest value of an array
- Filter custom post type by custom taxomony
- ordering and optimizing functions
- Why does order ASC break offset in WP_Query?
- new WP_query using custom fields
- Having Trouble Running Query From Shortcode Using Tribe’s Events Plugin
- Change ‘post_modify’ with a query
- An archive page without post format (just standard post)
- WordPress Query Returning Every Post
- Pagination showing same posts despite changing page
- shortcode with $atts with strange results
- Query custom post types by meta field in a term from custom taxonomy
- Display post format post in the sidebar