php - Incorrect Category Name showing on WP single post -


i editing wp site built years ago client developer, aren't in touch with.

on single post pages, there heading displays category name. posts of 1 of categories, showing name of parent category, not subcategory , reason. there 2 categories same parents ("news" , "events") – "events" displays correctly, "news" not.

the code display category name looks this:

<h2 class="section_header">      <?php     $category = get_the_category();     echo $category[0]->cat_name;     ?> </h2> 

here example. can see in address bar, post categorized under "news", yet displaying parent category ("happenings") in heading.

as comparison, can @ this post in category "events", parent "happenings", yet displays correct category title.

when checking off categories file post under, unnecessary check off parent. un-checking parent category post makes subcategory name display.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -