Custom post type loop without children

Question

I’ve created custom post type “Services” with 'hierarchical' => true,. My loop is simple:

    while (have_posts()) {
      the_post();
      get_template_part('content', get_post_type());
    }

In admin I have next structure:

  • Service 1
  • Service 2
    • Sub-service

The problem is that on Services page I have all of them. But I want only 1 level posts without children posts. And children posts should be inside parent post. How can I do that?

0
, , inferusvv 5 years 2017-10-30T02:39:30-05:00 0 Answers 89 views 0

Leave an answer

Browse
Browse