WordPress.org

Forums

Display Parent Category only.... (10 posts)

  1. bmg1227
    Member
    Posted 6 years ago #

    I'd like to have a line under the title that displays the usual "Filed Under", but want to only display parent categories.

    I normally use <?php the_category(', ') ?> but this obviously pulls the child categories too.

    Is it possible to display on parent categories, and if so, how?

  2. bmg1227
    Member
    Posted 6 years ago #

    Bump

  3. nico9
    Member
    Posted 5 years ago #

    i would like to know this too?

    is there a way to display the parent category without the child category?

  4. deanhatescoffee
    Member
    Posted 5 years ago #

    <?php the_category('depth=1') ?>

    That will show only the first level (depth=1) of categories.

  5. moshu
    Member
    Posted 5 years ago #

  6. nico9
    Member
    Posted 5 years ago #

    i tried
    <?php the_category('depth=1') ?>

    but there is no change it still displays the child category instead of the parent category.

  7. deanhatescoffee
    Member
    Posted 5 years ago #

    Aw snap, I'm sorry, I was thinking of wp_list_pages. My apologies.

    @ nico & bmg - This should do it:
    <?php echo "Category: ";the_category(','); ?>

  8. deanhatescoffee
    Member
    Posted 5 years ago #

    Bah, maybe not. Darn. I'm using this code on a friend's blog and it's only displaying the sub-category, not the main category. I do remember that at one time both the main and sub-categories were displayed, but now I can't seem to figure out how we figured that out.

  9. deanhatescoffee
    Member
    Posted 5 years ago #

    Oh wow, I completely confused myself into misunderstanding the purpose of this question. You want to show the parents, but not the child categories - I thought it was the other way around. Sheesh. Sorry 'bout that. I'm out of ideas. :)

  10. Cathy Tibbles
    Member
    Posted 5 years ago #

    I am searching the forums for the same question! Does anyone have an idea?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.