Checking if looped item has a parent inside a shortcode

Question

all I want is to check if the custom post item in the loop has a parent. I am using this inside a shortcode. I could not find how to access the property from inside the loop.

Thank you my dears

$q = new WP_Query(array(
    'post_type' => 'my_custom_post_type',

    'posts_per_page' => 5,
    'category' => '',
));

while ($q->have_posts()) {
      $q->the_post();
      ... <- Check if the loop item has a parent
}
wp_reset_postdata();
0
El Gringo 8 months 2020-11-26T09:10:25-05:00 0 Answers 10 views 0

Leave an answer

Browse
Browse