-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Follow up on the Post navigation link taxonomy filters #57949
Conversation
This was a leftover from when the inSameTerm was set with its own option, and it can be removed.
Size Change: -31 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in b069a1d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7581196456
|
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.
LGTM! I'll leave you with just one suggestion.
Insert the Post Navigation block into the Post Editor content
Backend
- ✅ For the default post type, only the taxonomy associated with the post can be selected as a filterable taxonomy.
- ✅ It also works as expected with the custom post type.
Frontend
- ✅ If the taxonomy is unfiltered, it always links to the previous or next post, regardless of the term.
- ✅ If the taxonomy is filtered, links to previous and next posts with the same term.
- ✅ It also works as expected with the custom post type.
Insert the Post Navigation block into the Single Posts template
Backend
- ✅ All taxonomies can be selected.
- ✅ "Nav Menu" and "Pattern Categories" are not displayed.
Frontend
- ✅ If the taxonomy is unfiltered, it always links to the previous or next post, regardless of the term.
- ✅ If the taxonomy is filtered, links to previous and next posts with the same term.
- ✅ It also works as expected with the custom post type.
if ( $taxonomy ) { | ||
$content = $get_link_function( $format, $link, true, '', $taxonomy ); |
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.
if ( $taxonomy ) { | |
$content = $get_link_function( $format, $link, true, '', $taxonomy ); | |
if ( ! empty( $attributes['taxonomy'] ) ) { | |
$content = $get_link_function( $format, $link, true, '', $attributes['taxonomy'] ); |
This may be a matter of personal preference, but I think this way of writing is simple. This allows you to delete line 102:
$taxonomy = isset( $attributes['taxonomy'] ) ? $attributes['taxonomy'] : '';
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 don't mind, done.
What?
This PR aims to address feedback on the post navigation link taxonomy filter:
#48912
Testing Instructions
Create three identical posts:
Add the posts to the "birds" category, or any new category that you want to add for the test.
Add the next and previous post navigation link blocks. Open the advanced panel and select category as the taxonomy.
View the first post on the front.
You should be able to navigate to the second post in the birds category, and from there, to the third post in the birds category.
When viewing the third post, the "next" link should not show.
Register a custom post type and custom taxonomy. The fastest way to do this is to enable a plugin with custom post types, I used https://wordpress.org/plugins/yoast-test-helper/.
Repeat the testing instructions above but use the custom post type and custom taxonomy (movie and genre for example).
Only the taxonomies supported by the post type should show in the taxonomy option.
Next, with a block theme active, please test the block in the Site Editor:
Go to Appearance > Editor > Templates, and edit the single post template.
Select or add the post navigation link blocks, and enable the filter under the Advanced panel.
Save the template changes.
Confirm that the placeholder in the Site Editor is the same, and that the correct posts are linked on the front of the website.