Child posts are related to their parents (through the “post_parent” field), and not vice versa. So you would have to query your child post type first, then get the parents of all the results.
// obviously these variable names and key names might not apply,
// change them as necessary
$performances = get_posts( array(
'meta_key' => 'the_performance_date_custom_field',
'meta_value' => $date,
'post_type' => 'performance' ) );
// extract the parent post ID's from each of the returned performances
$event_ids = array_map(
create_function('$post','return $post->post_parent'),
$performances );
$event_ids = array_unique( $event_ids ); // dump any duplicate events
// and finally, get the events from their ids
$events = get_posts( array(
'post_type' => 'event',
'post__in' => $event_ids ) );
Related Posts:
- 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
- Unable to display multiple post types in same query (WPML WP_Query)
- 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
- 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
- Secondary loop pagination on custom post type single post gets redirected to first page
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Loading post content in FancyBox
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- custom post type paging not working past page 3
- Loop through categories and create tab for each
- WP_Query search posts by custom post type and custom taxonomy
- List custom post type by custom tax term as page title
- How to dynamically attach pictures to a carousel
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- How to call a custom post type with WP_query
- How can I made custom taxonomies relationship?
- Pagination issue on category.php using custom post type query
- How to get all tags of a custom post type by id
- Listing all term items alphabetically / sorting loop
- Limiting posts_join, where, etc to a specific WP_Query object?
- What is the ID parameter for custom post types in query_posts?
- Create an archive page for custom post type with custom taxonomy
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- Undefined $post in wp_query
- Get current user id
- WP Query results showing posts outside of category ID
- List latest post out of 2 custom post types
- How to count other posts not having specific taxonomy terms?
- Running a custom query inside another cpt single and trying to grab a variable
- How to properly use Categories with Custom Post Types
- Displaying Portfolio Filter by Category Order (alphabetically)
- Query all posts under one taxonomy? Why is my code not working?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Wp Meta Query does not work while simple Query Works
- set object terms after some some time of published post – functions.php
- Change search query in wordpress custom post type
- Display related CPT with custom taxonomy
- Create a post automatically if search result has zero results
- Posts per Page on custom Taxonomy Template
- Linking posts together with Advanced Custom Fields “both ways”
- How do I get the posts from single page custom post type from a sidebar to display in a page?
- Custom post type not being pulled in widget
- Custom Taxonomy Query by Taxonomny not working
- query and paginate multiple post types
- Query posts by a type and another type only if post is in specific category
- Advanced Custom Fields: query posts filtered by multiple field values
- how to pass args for archive.php query?
- How to get Custom post type by related category ID
- How to insert a post from a different post type after every nth post
- Sort CPT by taxonomy AND THEN by custom field
- Complex Custom Loop with Includes