I had this problem with querying on two custom post types, using WP_Query. I had no problem querying for one type or the other in the array, but not both at the same time.
Did not work:
$args = array(
'post_type' => array('custom_type_1','custom_type_2'),
'posts_per_page' => 4
);
Did work:
$args = array(
'post_type' => array('custom_type_1'),
'posts_per_page' => 4
);
Did work:
$args = array(
'post_type' => array('custom_type_2'),
'posts_per_page' => 4
);
Awfully confusing to say the least.
Solved the problem by making sure that both custom post types had the “Make ‘Custom Post Type Name’ translatable” checkbox for WPML. WPML must not like it if you try to query on two post types where one is translatable and the other is not.
(I’m on WordPress 3.4.1 and WPML 2.5.2 – latest as of the date of this post)
Related Posts:
- WPML with WP_Query serving up all 3 languages [closed]
- Custom post type archive 404’s with paginate_links
- Display Custom Post Type Fields
- Retrieving 3 latest post from each of 5 different custom post types
- how to group custom post type posts by custom taxonomy terms
- Using Query Posts With Multiple Post Types And A Taxonomy
- How to get the parent’s taxonomy?
- Query not returning CPT posts
- Query for posts in 2 taxonomies
- Quickest way to get last or oldest post date – WP Query
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Custom query shows custom post types in trash
- Multiple post type queries (with specific arguments for each)
- Sorting multiple custom post types without a meta key/value pair by sort order
- Display custom post type from dynamic custom field
- Query/list all terms and their custom post count
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Get latest 3 posts from multiple CPT in one query
- Polylang non-default language ignores tags in WP_Query
- Different Ways to Query Custom Post Types?
- pagination not working for category.php (custom post types in categories)
- How to display Related Posts based on number of taxonomy terms matched
- How to make WP_Query not to show irrelevant posts?
- Loop for custom post types filtered by a taxonomy
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Pagination not working on custom query on a page
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- Can’t change posts per page in WordPress Post Type Query
- postsperpage value not being applied
- Custom Post Type Query W/Category Dropdown
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Sorting the Loop by Taxonomy Value
- Custom Query: Multiple CPTs and a taxonomy filter
- WP query_posts group by meta field related
- Custom wp-query display post only today
- custom post type and a “sticky” position taxonomy
- Use WP_query to match post types based on custom field values
- minimize wp_query call to database
- Query the title of the page to show posts with matching category in the loop
- Main site single-property.php design, as homepage of a multisite
- Imported Content Doesnt Show Up On Frontend
- WordPress custom post type
- display news with pictures 3 small and one large (loop)
- Custom Query With Multiple Meta Key Value
- Custom post type blog pagination conflict
- Query Posts From Multiple Post Types
- send user to first page of results when reposting to page?
- How do I correctly query posts from a post ID?
- How to exclude certain portfolios from a loop
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- Display ACF object field data using Elementor Custom Query
- Assign a tag to custom post type using a query
- Display all posts in a custom post type, grouped by a custom taxonomy
- Display a query with multiple post types and same relationship on a single page
- 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
- How to sort CPT by custom meta value (date), and return posts month by month
- Wp-query causing problems with the_content();
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- Custom post_type search’s $wp_query->query_vars do not correspond
- wp_query custom post type by taxonomy & standard post by taxonomy
- Query Custom Post Types & category_name?
- Conditional to modify query results
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WP Query to displaying date and posts for that date?
- Use WP_Query() to Output the 4th to 6th Most Recent Posts of a Custom Post Type
- Get all Posts If has same custom field values in Posts
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Custom-Posttype & Custom Taxonomy WP_Query
- Page template with different page and post content
- Stuck in Order by more then one
- Display featured image from one CPT within another CPT query
- Why is my category template ignoring post type?
- BBPress Search results in WordPress search
- Retrieve custom post types by custom taxonomies with WP_Query
- Custom taxonomy wp_query woes.
- Trouble with pagination
- attach CPT data to a taxonomy
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- Custom Post type loop with ACF not displaying properly
- How to query Posts from a custom post type which contains a custom taxonomy?
- 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
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- how to display new private message to users?
- 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
- WPML – Auto Duplicate Post Issue
- Loop carousel slider in wordpress
- Manually build WP_Query
- Optimise custom post type queries
- Loop with Custom Post Type and Taxonomies
- 404 on Pages for Custom Post Type & Query_Posts
- Query custom type posts by array of IDs