Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi again esmi,

    I’ve used explode() and it appears I’m getting an array of one: all categories are being output. They all get output again if I just echo the array iteration $parentcat[0]. Nothing comes up for $parentcat[1] and so on. If I output $parent_cats variable it doe indeed output “Array”. Do you know how I could break it down further so I can then go ahead and test it for ‘cat_is_ancestor_of’.

    $this_category = get_query_var('cat');
    $parent_cats = strip_tags( wp_list_categories('title_li=&depth=1&echo=0') );

    $parent_cats = explode(",", $parent_cats);

    foreach ($parent_cats as $parentcat) {
    echo "$parentcat";



    I’m not a php coder so some basic stuff eludes me – sorry.

    Thanks so much esmi –

    I’ve been troubleshooting around with this code you left, and I seem to have trouble getting
    strip_tags( wp_list_categories('title_li&depth=1&echo=0') );

    to return an array, I’m getting a string. How can I get it to return (or convert to) an array? Does echo=0 render it a string? can we create an array with get_terms()?

    Thanks again.

    Actually I have changed things a bit. My new question – altho related – is this:

    How do you get the topmost parent category, then it’s child’s children?

    Thanks t31os_ for that idea above to grab the subcategories and echo them out of the foreach loop.

    I was wondering if there’s an easy way to order this array by the date each one was created. I’m not loving the alphabetical (asc or desc) defaults.

    Just wondering…

    Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)