generated from pascalmartineau/wp-skeleton
fix: breadcrumbs ancestors
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 56s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 56s
This commit is contained in:
@@ -104,6 +104,18 @@ function ccat_get_post_breadcrumbs( WP_Post $post ) {
|
||||
|
||||
default:
|
||||
if ( ! empty( $post_id = get_option( "page_for_$post_type" ) ) ) {
|
||||
// Get ancestors of the archive page
|
||||
$ancestors = get_post_ancestors( $post_id );
|
||||
if ( ! empty( $ancestors ) ) {
|
||||
$ancestors = array_reverse( $ancestors );
|
||||
foreach ( $ancestors as $ancestor_id ) {
|
||||
$breadcrumbs[] = array(
|
||||
'label' => get_the_title( $ancestor_id ),
|
||||
'to' => str_replace( home_url(), '', get_permalink( $ancestor_id ) ),
|
||||
);
|
||||
}
|
||||
}
|
||||
// Add the archive page itself
|
||||
$breadcrumbs[] = array(
|
||||
'label' => get_the_title( $post_id ),
|
||||
'to' => str_replace( home_url(), '', get_permalink( $post_id ) ),
|
||||
|
||||
Reference in New Issue
Block a user