Adding Parent Category to Breadcrumbs
-
Hi there,
I was wondering if anyone would be so kind as to help me figure out how to add the “parent category” to my breadcrumbs hierarchy. Currently I am seeing Home > Category > Post but I would like to see Home > Parent Category > Category > Post. This is the code I’m currently using in my functions.php to display the “category”
add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2); function post_parent_trail ($crumbs, $args) { if ( is_singular('post') ) { $category = get_the_category( get_the_ID() ); if ( count( $category ) > 0 ) { $cat_array = array(); $cat_array[1]['label'] = $category[0]->name; $cat_array[1]['url'] = get_category_link( $category[0]->term_id ); array_splice($crumbs, 2, 0, $cat_array); } } return $crumbs; }The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Adding Parent Category to Breadcrumbs’ is closed to new replies.