[resolved] Get parent categories in an Array - only php (2 posts)

  1. shadez
    Posted 3 years ago #

    is there anyway to get the parents of category in an array, so that it can be displayed as a list? using only php or wp builtin functions?

    something like:

    $parentarray = get_category_parents( $cat, TRUE, "" );
    foreach ( $parentarray as $postparent ){
        echo "<li>  ". $parentarray ."</li>";

    above code doesnt work. anybody got a workaround?

  2. shadez
    Posted 3 years ago #

    ok this was easy... solved it myself using explore..

    $parentstr = get_category_parents( $cat, TRUE, "," );
    $parentarr = explode(",",$parentstr);
    foreach ( $parentarr as $catparent ){

    anybody got any better code pls share...

Topic Closed

This topic has been closed to new replies.

About this Topic