[resolved] How to show parent category names? (4 posts)

  1. WPChina
    Posted 9 years ago #

    I'm trying to print out the parent category with links of a sub category so it looks like this:

    Parent 1 >> Sub 1

    In the Codex I found this:

    <?php echo(get_category_parents($cat, TRUE, ' &raquo; ')); ?>

    However it is not printing anything--just blank.

    What code should I use to mark this up in PHP?


  2. WPChina
    Posted 9 years ago #

    Sorry for the bump, but I know this is a simple thing to do and I'm just stumped right now... the info in the Codex isn't working for me on WP2.2 :(

  3. MichaelH
    Posted 9 years ago #

    Where my child category is 4, this works for me:
    <?php echo(get_category_parents('4', TRUE, ' &raquo; ')); ?>

  4. WPChina
    Posted 9 years ago #

    Thank you MichaelH. Ok I see what I did wrong--I left off the number of the cat id and instead used the name. :-)

    Cheers for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic