-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Breadcrumbs: Add archive link if enabled in posts
#72832
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 archive link if enabled in posts
#72832
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. |
| * @return array Array of breadcrumb HTML items. | ||
| */ | ||
| function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) { | ||
| function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id, $post_type ) { |
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.
It feels non-ergonomic that we also have to pass the post type explicitly. I'd rather grab it from the $post_id:
$post_type = get_post_type( $post_id );In theory, it should be free to do that since the post object is already in the WP_Query.
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.
From one hand you're probably right because this block doesn't make much sense in blocks that update the block context manually (like Query Loop). On the other hand though why call another function (get_post_type) when we already have the info?
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 would agree if we had it inline, or if we didn't have it loaded from the database. But it should already be loaded, and we don't have it inline in that function either - we pass it between functions, and to do so we need to add an extra argument. This makes it less ergonomic, which is something to cosnider when designing functions and APIs.
That being said, I don't feel strongly about it, I don't think it's a major deal.
|
Flaky tests detected in 4869547. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19099291596
|
5cac11c to
2b42e7f
Compare
4869547 to
36fd1fa
Compare
04253f0 to
556af36
Compare
mcsf
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.
Looks good, thanks for accommodating!
There's just one thing that should be quickly addressable before merging:
Displaying both "Home" and "Post Archives" is weird, because they both point to /. I'm not sure what the best default would be for most users: to only keep the former or only the latter. For me I'd say only keep "Home".
There's another discussion, but probably best left for subsequent PRs: would most users prefer it if we defaulted to not showing the Post Archives item when it refers to the 'post' post type?
3b0734f to
1ba0014
Compare
I'd say the same, I'll create a follow up PR for this. |
Why do we have "Post Archives" for the |
Because we use get_post_type_archive_link and has extra logic for After that special handling the |
What?
Part of: #72498
This PR adds the
archivelink if enabled in posts, as it seems like a good default to have for the breadcrumbs.Testing Instructions
has_archiveenabled and disabled.Screenshots or screencast
Below I'm sharing some screenshots in a site that I've added @justintadlock's plugin and the core block in the main header.
Above is x3p0-breadcrumbs/ and below is the core block.
CPT with terms
CPT without terms
Hierarchical CPT with ancestors