• Hi all,

    I created a custom post type “Products”, and created also categories for that custom post type (so using custom taxonomies). These categories are 5: “Products” (main), and its children, “first”, “second”, “thirth”, “fourth” (their template is managed by “archive.php”).

    When I am in the page of the single category (which shows the list of all the posts of that category), for instance “second”, everything is ok: I can show the category title with this code:


    <?php
    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    echo $term->name;
    ?>

    But when I am in the single page of a post of that category (managed by the template “single-products.php”), for instance “Prodotto 1” of the “second” category, the code doesn’t work. I need to show somewhere in this page that “Product 1” is in the category “second”.

    Thanks a lot!

  • The topic ‘Show the title of the term inside the single custom post type’ is closed to new replies.