Results 1 to 5 of 5

Thread: Display multiple categories on post!

  1. #1
    Thread Starter
    Rookie g-saint's Avatar
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display multiple categories on post!

    Does anyone know how to display all the categories/subcategories... that belongs to a particular post in a post?

    First, I tried this:

    Code:
    <?php
    foreach((get_the_category()) as $category) {
    echo $category->cat_name . '
    '; 
    echo '[*]' . $category->cat_name . '';
    } 
    ?>
    The problem is that it doesn't order by:
    PARENT CATEGORY
    - Sub Category
    -- Sub Sub Category

    It simply displays all the categories together, so you can't tell what is a parent or a child category. I've tried looking up on the internet, but nobody has an example of this.

    If someone knows how to show them on a post and on one of the index.php "columns", it would be a big help...

    Cheers,

    Gabriel

  2. #2
    Junior Member egm1947's Avatar
    Join Date
    Jun 2009
    Location
    United States
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Display multiple categories on post!

    Are you using version 2.9.2? I don't have that problem.

  3. #3
    Thread Starter
    Rookie g-saint's Avatar
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display multiple categories on post!

    Yes, I'm using 2.9.2!

    Have a look below:

    INDEX: http://gostudy.com.au/courses/
    POST: http://gostudy.com.au/courses/elicos/sample-school/

    Where:
    * Business English (CHILD)
    * ELICOS (PARENT CATEGORY)
    * General English (CHILD)

    That's how it shows...

  4. #4
    dubya's Avatar
    Join Date
    May 2009
    Location
    Canada
    Posts
    1,000
    Thanks
    115
    Thanked 107 Times in 93 Posts

    Re: Display multiple categories on post!

    Interesting use for ClassiPress
    It looks like they are being sorted alphabetically (default?)
    Is there a snippet of code that will change the sort order to hierarchical? I'll bet someone in here can help you out.
    The search button. Your new best friend.
    - Dubya

  5. #5
    Rookie
    Not a Verified Customer
    laketa's Avatar
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display multiple categories on post!

    I had the same problem you have, and I got to order my categories non-alphabetically by using a plugin named order-categories. With this plugin you can order your categories from the "posts" menu by dragging and dropping, it's very simple.
    Hope this may help you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)