fix: breadcrumbs ancestors
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 56s

This commit is contained in:
2025-09-24 16:20:32 -04:00
parent add3869f43
commit 1817772c50

View File

@@ -104,6 +104,18 @@ function ccat_get_post_breadcrumbs( WP_Post $post ) {
default: default:
if ( ! empty( $post_id = get_option( "page_for_$post_type" ) ) ) { 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( $breadcrumbs[] = array(
'label' => get_the_title( $post_id ), 'label' => get_the_title( $post_id ),
'to' => str_replace( home_url(), '', get_permalink( $post_id ) ), 'to' => str_replace( home_url(), '', get_permalink( $post_id ) ),