Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WordPress – Can’t Get Parent and Child Categories of Custom Taxonomy to Display

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #34668
    dugost
    Member

    I have a Custom Post Type set up with a Custom Taxonomy. For this Custom Taxonomy, I’m trying to figure out how to echo out the titles of the parent category and current child category within it.

    This is the set-up:

    prints (registered custom post type)

    print_type (registered custom taxonomy)

    Prints & Note Cards (parent category in print_type taxonomy)
    Floral Prints (child category)
    Scenic Prints (child category)
    Note Cards (child category)
    Selection (child category)

    On single-prints.php I would like to display the following (individually, not as a list):

    Parent Category / Current Child Category / Post Title

    None of that needs to be linked, I simply want the text in order to display the hierarchy. I’ve tried dozens of bits of code to display the two types of category titles without any luck. I’ve been told I need to use some form of get_terms as well but nothing I try works.

    I’m new to WP and PHP and I’m very frustrated since can’t seem to wrap my head around what I’m doing that’s wrong. Here’s the page code:








    $category = get_the_category();
    echo $category[0]->cat_name;
    ?>

















    From all of the tutorials on CPTs I’ve read, using single-my_post_type.php is correct. Everything is working well except this one particular issue. Perhaps what I’m looking to do can’t be done natively in WP so do I need to write a function? Do I need to be using a different page type or have it named differently?

    Any help is greatly appreciated.

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.