• With this code parent term page lists all the child terms and the child term page lists all of the posts in current term, and the single page lists a big flat list of terms(hierarchical).

    Now,

    The parent term page is fine.

    When it’s child term page, i want to list all child terms( not showing with this code ) + the posts in current term( showing ).

    And when it’s single post, i want to list the same as child term page.

    $term = get_queried_object();
            $tax = 'ntp_package_type';
            $parents = $term->parent;
            $term_id = $term->term_id;
    
            if($parents == 0){
                wp_list_categories( array (
                                'taxonomy'  => 'ntp_package_type',
                                'pad_counts'=> 0,
                                'title_li'  => '',
                                'child_of'  => $term_id,
                                )
                );
            }
            elseif (is_tax($tax, $term->name)){
    
                $args = array(
                        'post_type' => 'ntp_package',
                        $tax => $term->name,
                );
                $wp_query = new WP_Query($args);
                if( $wp_query->have_posts() ):
                while ( $wp_query->have_posts() ) : $wp_query->the_post();
                echo "<p><a>".$post->post_title."</a></p>";
                endwhile;
                endif;
    
            }
            elseif (is_single()){
    
            }

    It is for a sidebar sub nav. is it a right way to do? I’d really appreciate any help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you wrap code using Backticks or the (code) button above your post?

    Thread Starter awesome

    (@nookaround)

    Hey i tried it says, “Post is too old”, what’s that?

    Moderator keesiemeijer

    (@keesiemeijer)

    Hey i tried it says, “Post is too old”, what’s that?

    Users can edit a post for up to 60 minutes from the time of submission. After that, the post can only be edited by a moderator.

    I edited your post so that the code is formatted correctly.

    Thread Starter awesome

    (@nookaround)

    @keesiemeijer Thank you.

    have you read the question?
    i just need to concatenate the result of wp_list_categories to the is_tax() result.

    when i assign wp_list_categories to a variable and echo it outside the if ($parents == 0 ) it produces null.

    is there any way i can achieve this submenu.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘In a list of terms show the posts in a current term next to it(current term)’ is closed to new replies.