Skip to content

Commit

Permalink
Allow breadcrumb without parents to render if site title and current …
Browse files Browse the repository at this point in the history
…page options are enabled
  • Loading branch information
andrewserong committed Jun 5, 2023
1 parent 4cebc39 commit e12b350
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/block-library/src/breadcrumbs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {

$ancestor_ids = array();
$has_post_hierarchy = is_post_type_hierarchical( $post_type );
$show_site_title = ! empty( $attributes['showSiteTitle'] );
$show_current_page = ! empty( $attributes['showCurrentPageTitle'] );

if ( $has_post_hierarchy ) {
$ancestor_ids = get_post_ancestors( $post_id );

if ( empty( $ancestor_ids ) ) {
if (
empty( $ancestor_ids ) &&
! ( $show_site_title && $show_current_page )
) {
return '';
}
} else {
Expand All @@ -53,7 +57,7 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {

// Prepend site title breadcrumb if available and set to show.
$site_title = get_bloginfo( 'name' );
if ( $site_title && ! empty( $attributes['showSiteTitle'] ) ) {
if ( $site_title && $show_site_title ) {
$site_title = ! empty( $attributes['siteTitleOverride'] ) ?
$attributes['siteTitleOverride'] :
$site_title;
Expand Down

0 comments on commit e12b350

Please sign in to comment.