-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Breadcrumbs: Add post type archive link if it's not the same as home url #73435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breadcrumbs: Add post type archive link if it's not the same as home url #73435
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in d65750a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19506977610
|
| // 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'] ) ) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
tyxla
left a comment
There was a problem hiding this 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.
779b655 to
7db67c5
Compare
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
postpost 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 forpostpost 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
Your latest postsin reading settings should be selectedshow home linkblock attribute (inspector controls) enabled, front end of any post should not render the post type archive linkshow home linkblock attribute disabled, front end of any post should render the post type archive linkScreenshots 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 linkenabledCPT with archive and different URL is the same as before
Posts with
show home linkdisabled