• Hi,

    I’ve been customizing WordPress to be used for my portfolio site and I came across with an issue.

    I want to display the name of sub-category as a header for the category. I’m using the code below which was given by someone (much appreciated!)

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

    It works fine except that if there is any post which has more than one category assigned WordPress only displays the younger ID number’s category name. For example I have one post which is in “Illustration” (id=5) and “Painting” (id=8) under the parent category “Work” (id=2). If you go to the “Painting” category page the title header says “Illustration” and it won’t display “Painting”.

    I looked around but I couldn’t find anyone who had the same issue. If anyone of you have had teh same problem and resolved it please let me know. Many thanks!

    AD

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Agent D

    (@agent-d)

    Hmm… I still can’t figure this out. Anyone has any idea?

    AD

    Thread Starter Agent D

    (@agent-d)

    I solved it!!

    <?php echo single_cat_title(); ?>

    I can’t believe how simple it was. Thanks Jessn! I saw your past post ??

    AD

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying sub-category name issue with multiple categories’ is closed to new replies.