You can use the post_parent__not_in
parameter:
$args = array(
'post_type' => 'cpt',
'post_parent__not_in' => array( 0 )
);
$query = new WP_Query( $args );
to retrieve child posts of type cpt.
The generated SQL will then include this part:
wp_posts.post_parent NOT IN (0)
Related Posts:
- Parent / Child formatting in a list of post of a custom post type
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- Display posts of a hierarchical custom post type excluding parent posts
- Most efficient way of showing children posts?
- Display all posts in a custom post type, grouped by a custom taxonomy
- 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
- Sorting a query by custom field date
- Enforcing canonical URLs with multiple custom post types
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- 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
- Query by 2 values of a repeater ACF field
- Display two post types ordered by two custom fields
- Post type hierarchy
- Display children and grandchildren of a custom post type
- Getting all custom posts with a certain category
- Sort by two dates. Default entry date and custom field if present
- Querying CPT with Two Taxonomies
- Custom Query to display posts with custom field
- Get taxonomy description based on variable
- Custom post_type search’s $wp_query->query_vars do not correspond
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Conditional to modify query results
- Use WP_Query() to Output the 4th to 6th Most Recent Posts of a Custom Post Type
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Can I create a loop with multiple post types and specify different $args for each post type?
- How to get the parent of a non-hierarchical custom post type being edited in Gutenberg
- Display custom post type from dynamic custom field
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Previous/Next Link by Meta Value in CPT
- Custom-Posttype & Custom Taxonomy WP_Query
- Stuck in Order by more then one
- Display featured image from one CPT within another CPT query
- How do you paginate a query grouped by month?
- Query Custom Post Type Taxonomy term with multiple parameters
- Why is my category template ignoring post type?
- pagination not working for category.php (custom post types in categories)
- Query based on custom fields start and end date
- Create a permalink structure with custom taxonomies and custom post types gives 404
- Retrieve custom post types by custom taxonomies with WP_Query
- 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
- Custom Post type & Taxonomy 404
- 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.
- 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
- Different options per post type in WP_Query
- Returning a custom content types with meta values
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- Creating a non-hierarchical Taxonomy that behaves like categories
- Custom Post type loop with ACF not displaying properly
- Sort results without WP_QUERY?
- Using Wp_Query, Json to add Highcharts series data
- Display the current post in browser as the first post in a loop (for a slideshow)
- Searching post types
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- wp_query not returning my custom post
- Does “Custom Post Type” can have page hierarhy option?
- Get_the_term_list inexplicably adds values in foreach
- Single parent post lists child posts with pagination
- custom taxonomy pagination 404 error
- wp_query can’t get max_num_pages in custom post type
- 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
- 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?
- how to display new private message to users?
- Custom post types & Pages hierarchy – Error 404
- subtracting the current post form then whole loop, which is generating all CPT titles
- Create a Hierarchical List of Custom Taxonomies AND Posts
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Imported Content Doesnt Show Up On Frontend
- Loop carousel slider in wordpress
- Manually build WP_Query
- How can I add a “fake” parent into the permalink?
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- 404 on Pages for Custom Post Type & Query_Posts
- 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)
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Default WordPress Query for a Specific Custom Post Type URL
- Sort ACF by custom taxonomy
- Dynamically count the number of custom post types associated to a custom taxonomy