-
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
Add tag selector to latest posts widget, add tag selector to queries #19755
Add tag selector to latest posts widget, add tag selector to queries #19755
Conversation
Fixes #13027 |
First ever PR on Gutenberg! |
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 have rebased and tested this and the problem is that the posts don't appear because of a bad argument to get_posts.
However even fixing that, I am unsure of tags being best selected by a dropdown, we should have an autosuggest open entry field. Tags, unlike categories, tend to be many, and that select would become impossible to track with the mouse.
@@ -25,6 +25,10 @@ function render_block_core_latest_posts( $attributes ) { | |||
$args['category'] = $attributes['categories']; | |||
} | |||
|
|||
if ( isset( $attributes['tags'] ) ) { | |||
$args['tag'] = $attributes['tags']; |
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.
$args['tag'] = $attributes['tags']; | |
$args['tag_id'] = $attributes['tags']; |
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.
WP_Query args expect the tag
argument to be one or more slugs.
export default function TagSelect( { label, noOptionLabel, tagsList, selectedTagId, onChange } ) { | ||
const termsTree = buildTermsTree( tagsList ); | ||
return ( | ||
<TreeSelect |
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 wonder if this is the best form input to use. Isn't the one used at document level tag assignment better TokenInput
?
Howdy @eriktdesign and congrats on your first PR here and welcome! I have added a review with two requests but other than that things look all right :) This will be an important addition to the next phase of the |
Since there has been almost a month of no activity here and given that #20785 is more advanced into implementing multiple tag filters I will close this PR. Thank you @eriktdesign. This was the base PR for #20785! |
Description
Add a selector to filter by tags to the Latest Posts block. Modeled on the Categories filter, works the same way.
How has this been tested?
Tested in WP 5.3.2 on TwentyTwenty using Local running PHP 7.3.2. Passes the test suite. Added a file in the QueryControls module called tag-select.js -- it is a nearly exact copy of category-select.js, just changes variable names to use tags.
Screenshots
Types of changes
New feature: Adds a Tag selection dropdown to the "Latest Posts" block
New feature: Add tag selection to QueryControl
Checklist: