0

I use this code to show the current page category parents, but I don't want it to include the current page category.

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

1 Answer 1

1

The easiest way to do this, is by retrieving the direct parent of the current page category and then use get_category_parents on that category. Like this:

// supposing $cat contains the category ID
// load category object
$cat_obj = get_category ($cat);
// retrieve parent ID from object;
$parent = $cat_obj->parent;
// retrieve list of parent categories without current category
echo get_category_parents ($parent, true, ' &raquo; ');

(Untested but should work)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.