ancestors (for hierarchical * post types) -> the post itself. Single source of truth shared by the * BreadcrumbList schema node and the visible `[acez_seo_breadcrumbs]` * shortcode, so both stay in sync. */ final class BreadcrumbTrail { /** * @return array */ public static function items( \WP_Post $post ): array { $items = array( array( 'name' => get_bloginfo( 'name' ), 'url' => home_url( '/' ), ), ); if ( 'page' === $post->post_type ) { $ancestors = array_reverse( get_post_ancestors( $post ) ); foreach ( $ancestors as $ancestor_id ) { $items[] = array( 'name' => get_the_title( $ancestor_id ), 'url' => (string) get_permalink( $ancestor_id ), ); } } $items[] = array( 'name' => get_the_title( $post ), 'url' => (string) get_permalink( $post ), ); /** * Filters the breadcrumb trail items for a post. * * @param array $items * @param \WP_Post $post */ return (array) apply_filters( 'acez_seo_breadcrumb_trail', $items, $post ); } }