Skip to content

Conversation

@ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Nov 19, 2025

What?

Follow up of: #72832
Resolves: #73442

This PR checks whether the post type archive link is the same with the home url, and in that case it doesn't add the extra breadcrumb item.

This happens because internally we use get_post_type_archive_link that has extra logic for post and page and that results in displaying the archive link even for post post type.

Additionally it resolves #73442. If we've set a specific page for posts page, the breadcrumb label is the page title. This is the case only for post post type and not CPTs.

Testing Instructions for #73442 - see at that issue

Testing Instructions for not showing the post type archive link if it's same with home url

  1. Enable GB experimental blocks.
  2. For easier testing I'm adding this plugin and the core block in theme's header and test various cases in the front end.
  3. Your latest posts in reading settings should be selected
  4. With show home link block attribute (inspector controls) enabled, front end of any post should not render the post type archive link
  5. With show home link block attribute disabled, front end of any post should render the post type archive link

Screenshots or screencast

Below I'm sharing some screenshots in a site that I've added x3p0-breadcrumbs plugin and the core block in the main header.
Above is x3p0-breadcrumbs and below is the core block.

Posts with show home link enabled

Before After
Screenshot 2025-11-19 at 5 15 23 PM Screenshot 2025-11-19 at 5 10 06 PM

CPT with archive and different URL is the same as before

Screenshot 2025-11-19 at 5 09 58 PM

Posts with show home link disabled

Screenshot 2025-11-19 at 5 25 16 PM

@ntsekouras ntsekouras requested review from mcsf and tyxla November 19, 2025 15:35
@ntsekouras ntsekouras self-assigned this Nov 19, 2025
@ntsekouras ntsekouras added [Type] Enhancement A suggestion for improvement. [Block] Breadcrumbs Affects the Breadcrumbs Block labels Nov 19, 2025
@github-actions
Copy link

github-actions bot commented Nov 19, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: mcsf <mcsf@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: justintadlock <greenshady@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Flaky tests detected in d65750a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19506977610
📝 Reported issues:

// Add post type archive link if applicable.
$post_type_object = get_post_type_object( $post_type );
$archive_link = get_post_type_archive_link( $post_type );
if ( $archive_link && ( ( $attributes['showHomeLink'] && home_url() !== $archive_link ) || ! $attributes['showHomeLink'] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking out of laziness: should we run both URLs through untrailingslashit before comparing them, or is this robust enough? Reasons for asking: 1) paranoia, 2) the fact that home_url and post_type_archive_link are filterable, 3) seeing some calls to user_trailingslashit in get_post_type_archive_link.

Also: what happens (and what should happen) when the current post type has its archive page at the home URL, but we are paginating?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added untrailingslashit. I had seen all the filters used and in general it doesn't seem failproof even with that TBH, with all the filters used. But it should work alright in most cases I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: what happens (and what should happen) when the current post type has its archive page at the home URL, but we are paginating?

I think this is handled alright with the paged in home and post type archive, and should show the page X.

@mcsf mcsf changed the title Breadcrumbs: Add post type archive link if it's not the same with home url Breadcrumbs: Add post type archive link if it's not the same as home url Nov 20, 2025
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing great, thanks 👍

Just a few questions.

@ntsekouras ntsekouras force-pushed the breadcrumbs-add-post-type-archive-if-not-same-with-home branch from 779b655 to 7db67c5 Compare November 20, 2025 15:01
@ntsekouras ntsekouras enabled auto-merge (squash) November 20, 2025 15:02
@ntsekouras ntsekouras merged commit 09eeecb into trunk Nov 20, 2025
73 checks passed
@ntsekouras ntsekouras deleted the breadcrumbs-add-post-type-archive-if-not-same-with-home branch November 20, 2025 15:38
@github-actions github-actions bot added this to the Gutenberg 22.2 milestone Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Breadcrumbs Affects the Breadcrumbs Block [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breadcrumbs: Consider using Posts Page title for post archives crumb

4 participants