• Hello
    My structure is:
    -Category(level1)
    –Post1
    –Post2
    –Category2(level2)
    —Post
    —Post

    I want to show only the first level posts, i tried this code but it shows me all posts:

    <?php 
    $args = array(
                  'post_type' => 'knowledgebase',
                  'tax_query' => array(
                                 array(
                                    'taxonomy' => 'knowledgebase_category',
                                    'terms'    => 31,
                                    'hide_empty' => false,
    
                        ),
                      ),
                    );
    
                        $catquery = new WP_Query( $args );
    
                        echo '<ul>';
    
                            while($catquery->have_posts()) : $catquery->the_post();
    
                            echo"<li>
    
                            the_title();
    
                            echo "</li>";
                            endwhile;   
    
                        echo '</ul>';
    ?>

    Thank you

    • This topic was modified 8 years, 4 months ago by fariss49.
  • The topic ‘Display level1 posts in a specific category’ is closed to new replies.