I'm using a WP_Query to query my custom post type posts. This custom post type has parent and children pages. I'm trying to pull the first parent page. How would I do this?
$parent_only_query = new WP_Query(array(
'post_type' => 'my-custom-post-type',
'post_parent' => 0
));
while ($parent_only_query->have_posts()){
$parent_only_query->the_post();
// etc...
}
wp_reset_query(); // if you're not in your main loop! otherwise you can skip this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With