Skip to content

Commit 6867ee7

Browse files
committed
Included podcasts to breadcrumbs
1 parent a978763 commit 6867ee7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

themes/osi/template-parts/breadcrumbs.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,31 @@
88
$post_type = is_page() ? 'page' : get_query_var( 'post_type' );
99
$is_post_type_hierarchical = is_post_type_hierarchical( $post_type );
1010

11+
// Special handling for podcast post type
12+
if ( $post_type === 'podcast' ) {
13+
$breadcrumb = '';
14+
$position = 1;
15+
$podcast_archive_url = home_url( '/ai/podcast/' );
16+
17+
if ( is_archive() || is_post_type_archive( 'podcast' ) ) {
18+
$breadcrumb .= '<span class="current-page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="' . esc_attr( $position ) . '"><span itemprop="name">Podcast</span></span>';
19+
} else {
20+
$breadcrumb .= '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="' . esc_attr( $position ) . '"><a href="' . esc_url( $podcast_archive_url ) . '" itemprop="item"><span itemprop="name">Podcast</span></a></span>';
21+
++$position;
22+
23+
$post_id = get_queried_object_id();
24+
$breadcrumb .= '<span class="current-page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="' . esc_attr( $position ) . '"><span itemprop="name">' . esc_html( get_the_title( $post_id ) ) . '</span></span>';
25+
}
26+
27+
$home = '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="0"><a href="' . esc_url( home_url( '/' ) ) . '" class="home-link" itemprop="item" rel="home"><span itemprop="name">' . esc_html__( 'Home', 'jetpack' ) . '</span></a></span>';
28+
29+
echo '<nav class="entry-breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">' . $home . $breadcrumb . '</nav>'; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
30+
echo '</div></div>'; // Close the breadcrumb area
31+
return;
32+
}
33+
1134
if ( ! ( $is_post_type_hierarchical || $is_taxonomy_hierarchical ) || is_front_page() ) {
35+
echo '</div></div>'; // Close the breadcrumb area
1236
return;
1337
}
1438

0 commit comments

Comments
 (0)