WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. shadez
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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