Support » Fixing WordPress » Show the top category name

  • Hi!

    Is there a way to show, on my post page, ONLY the top category?
    If I have a structure like “MOVIES > DRAMA”, I am able to show “DRAMA” on it. But I would like to show ONLY “MOVIES”. How can I do that?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Assuming Movies (parent Category) is Category ID 5 and Drama Category (child Category) is 16, you could create a Category Template, category-5.php to show only the posts in the Movies Category.

    I’ll amend that previous statement above, as clicking on a Category link for a parent Category does show the posts that belong to both parent and the children Categories.

    But, to a Category Template, you can add this construct inside your loop to limit the posts to a specific category:

    if ( in_category(get_query_var('cat')) ) {
    // display your post stuff here

    Ok, thanks MichaelH!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show the top category name’ is closed to new replies.