WordPress.org

Ready to get started?Download WordPress

Forums

how do i get the top level cateogry name? (2 posts)

  1. jjcalleiro
    Member
    Posted 6 years ago #

    I am trying to print out the name of the top level categories. i have some categories that have 10 children. the code i am using is the following.

    $category = get_the_category();
    $current_category = get_cat_name($category[0]->category_parent);
    echo $current_category;

    While this seems to work for the first child in the tree any below show up blank.

    Thanks in advance for your help!

  2. MichaelH
    Member
    Posted 6 years ago #

    The depth=1 parameter with the template tag, wp_list_bookmarks(), will display all 'top level' cats.

Topic Closed

This topic has been closed to new replies.

About this Topic