From 1817772c509dcca276e31d64bbce3adc6bf50c53 Mon Sep 17 00:00:00 2001 From: Pascal Martineau Date: Wed, 24 Sep 2025 16:20:32 -0400 Subject: [PATCH] fix: breadcrumbs ancestors --- .../themes/ccat/includes/graphql/breadcrumbs.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wp-content/themes/ccat/includes/graphql/breadcrumbs.php b/wp-content/themes/ccat/includes/graphql/breadcrumbs.php index 529b5d1..2483c29 100644 --- a/wp-content/themes/ccat/includes/graphql/breadcrumbs.php +++ b/wp-content/themes/ccat/includes/graphql/breadcrumbs.php @@ -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 ) ),