Skip to content

Breadcrumbs block: post_type_archive_title has no effect on single page #75040

@benoitchantre

Description

@benoitchantre

Description

When you change the default post type archive title, you can see it works when on a post type archive page, but there's no effect on the content displayed by the breadcrump for a single post.

Without changing the post type archive title :

  • archive page : Home > Events archive
  • single page : Home > Events archive > Term name > Post title

When using the post_type_archive_title hook to rename the post type archive title :

  • archive page : Home > Events
  • single page : Home > Events archive > Term name > Post title

I have used the following function to rename the post type archive title

function rename_archive_title( string $title ): string {
	$post_type        = get_query_var( 'post_type' );
	$post_type_object = get_post_type_object( $post_type );

	return $post_type_object->labels->name ?? $title;
}
add_filter( 'post_type_archive_title', __NAMESPACE__ . '\rename_archive_title', 10 );

Step-by-step reproduction instructions

  1. Change the post type archive title using the post_type_archive_title filter hook
  2. See that it works on the breadcrumb displayed on the archive page
  3. See that it has no effect on the breadcrumb displayed on the single page

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions