WordPress.org

Support

Support » Themes and Templates » [Resolved] List custom post types for the current custom taxonomy

[Resolved] List custom post types for the current custom taxonomy

  • Hello!

    How can I show in a page of a custom post type, a list of the custom post types from the same taxonomy, in case there are several defined?

    For example, in a portfolio, if there are taxonomies “design” and “photography” when I see a project for design, I want to have all design projects listed.

    Seems easy, but I don’t know how to do it. Thank you!! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try this

    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    
    query_posts($query_string . "&cat=".$term->term_taxonomy_id);

    Thank you!! 🙂

    How do you use this on a sidebar.php?

    I want to do this exact thing, but in my custom sidebar.php Every time I use this code I get unexpected results on the sidebar. Can someone post an actual code example for a sidebar?

    Khaled Hakim

    @khaledhakimgmailcom

    Isaachorton, try coping the same code buy by enclosing it with <?php and ?> tags…

    <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    
    query_posts($query_string . "&cat=".$term->term_taxonomy_id); ?>

    Let me know if that works for you.

    Nice code!

    How do I get ‘term’ and term_taxonomy_id?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] List custom post types for the current custom taxonomy’ is closed to new replies.
Skip to toolbar