Repository navigation
Description
There have been some recent additions to the toolbar controls for the Query block. Before we go too far, let's evaluate what we have currently.
Posts per page
This is an important setting, however, will the Query block every produce results that include anything other than posts? My suggestion is to change this to say, "Items per page" and make sure it is in Sentence case, not Title case.
Number of Pages
I think this one can change to a toggle that says, "Show more than one page". The reason being is that the current "number of pages" doesn't allow a default that just shows however many pages are required to display all the posts. And it seems likely that users will want to only show ONE page with a few results, or show ALL pages with a set list of results per page. Of course toggling this "on" would add the Query Pagination block automatically if needed.
Offset
This is good to keep, but needs some explanation (helper text). At first I wasn't sure what this did. Can we add some text below that offers a tip? "Offsetting a list to 3 will begin the results at the 3rd item instead of the 1st."
Categories & Tags
I like that these are added for the basic Query block, but I imagine they will be hidden depending on the template for which they're being used. Like if this block is used on a category-$slug.php page, I would assume the Tag settings would not be available. Nor would the Category settings be available because the template would pass the parameters directly to the block. Am I thinking about this correctly?
Add "Order by" sorting
Let's add the "Order by" sorting option to this list as well.
New mockup
With these design changes, the toolbar popover should look something like this:
cc @ntsekouras


Activity
mapk commentedon Sep 9, 2020
Order by
I realize the "Order by" was added here: #24691 to the Inspector, but I thought it might work well in this popover. Now, I'm second guessing this one because it doesn't feel like an important setting required for the use of this block. Chances are, this particular setting won't get a lot of use as most people will prefer the default of "Newest to oldest".
Filter by Author
The ability to filter by "Author" was added here: #25149. Regarding my comment above about Categories and Tags, should the Author option also hide depending on the template being used? For example, if I'm adding this block to a
author-$id.phptemplate, I probably don't need this setting, right?ntsekouras commentedon Sep 10, 2020
Hey @mapk! I don't have many answers myself yet, but here are some of my thoughts :)
In the first design iteration I think we should probably change the
items per pageandoffsettonumbercontrols and notrange. I can't think of any reason for them to berange. If anyone does, please comment.Number of Pages
That seems right, probably with different wording, like
show pagination.Offset
An explaining text seems a good idea to me.
Categories & Tags
I would like to hear some thoughts from people more involved in FSE as well.
Order by
This seems to be a
secondaryoption for inspector controls.Filter by Author
Even if this is conditionally shown, we should decide where to show it. It seems to me a bit more of inspector controls item.
ntsekouras commentedon Sep 10, 2020
Also keep in mind that another
controlwill be added for sure that is thesearchcontrol which require a text input. This will be probably needed for any context.mapk commentedon Sep 10, 2020
That's right! I remember you mentioning this before. I'm on board with this.
Maybe. I think whatever we use for copy will need to be flexible enough that if the results only fill one page, it still makes sense. I'll add the "Needs copy" label to get some thoughts.
Also cc-ing @mtias to get your input on this. We're iterating on the settings for the Query block and can use some feedback regarding this particular issue.
mapk commentedon Sep 10, 2020
Here's a mockup including some of these changes.
mapk commentedon Sep 10, 2020
I received some recent feedback that has encouraged me to explore a basic Query block with all the settings, whether in the toolbar or sidebar, first. From there we can explore the variations that may hide certain settings, or show settings preconfigured (and possibly uneditable if inherited from template).
There was also some thoughts on whether or not
Offsetis important enough to be in the toolbar dropdown.will have another iteration up today
carolynannewells commentedon Sep 10, 2020
Hello! Popping in here from editorial. I like what you are doing here, you are making things much clearer, especially with the explaining text. I would perhaps change the "Show more than one page" toggle to "Show multiple pages."
mapk commentedon Sep 11, 2020
Thanks, @carolynannewells! I actually iterated a bit more earlier today and landed on, "Allow pagination of results" What do you think about that one? I'm totally willing to trust your expertise here!
I've also made some adjustments as another iteration. This is isn't quite final. Just wanted to share my progress from today.
Option 1 - Two setting buttons in toolbar
Notes
Option 2 - Inline filter input fields
Riffing off of the work in the new Link UI, I also wanted to share some explorations I did around the filters. Hat tip to @MichaelArestad for suggesting this. I pulled the filters out into their own icon buttons in the toolbar. When clicked, they open up just like the link UI does. I'm not confident about this direction, but thought it could spur more feedback.
Prototype

Annotated

Mockups

Mockups with a "Is" or "Is not" selection box.

carolynannewells commentedon Sep 11, 2020
I think that "Allow pagination of results" works! :)
scruffian commentedon Sep 11, 2020
Could "categories" and "tags" be dropdowns rather than inputs?
mapk commentedon Sep 11, 2020
Yes! 😄 I think something like what is in place currently would be great. I'm going to refine those controls further.
45 remaining items
mariohamann commentedon Oct 14, 2020
Filters
I think it is a very good idea to stick to common behaviour with the filters → Really like the new explorations @mapk . 👍🏻 Building on @ItsJonQ proposal I had this quick idea I would like to bring in:
Clicking on "Open condicitional builder" opens a modal, which influences the shown JSON. Maybe it's too "technical" but maybe it helps for further explorations. :)
Sticky posts
tl;dr
For sticky posts the current UI seems to behave as a boolean (include, show only?), but we need three options (include, exclude, show only). Furthermore we need the option to "ignore_stickiness". @ntsekouras What are the planned options from code perspective?
Explanation
In the REST API (referring the docs) we have the parameter
sticky[boolean], saying "Limit result set to items that are sticky." Therefore we have 3 options.: If not set, sticky and non-sticky posts show up. (Default)sticky=true: include only sticky posts (corresponding to'post__in' => get_option( 'sticky_posts' )in WP_Query)sticky=false: exclude sticky posts (corresponding to'post__not_in' => get_option( 'sticky_posts' )in WP_Query)🔍 Example "Featured posts" and "Other posts": If one wants to list all featured (=sticky) posts in one
Querye. g. with big pictures etc. and all other posts (= non sticky) in anotherQuerywithout images, we need the option to include and exclude. If we only have the option to include only sticky posts, they would show up in bothQueries.Furthermore in WP_Query we have the parameter to
ignore_sticky_posts. This ignores the "stickiness" of posts. If set, sticky posts still are shown but not at the top of the output. I couldn't find this option in the REST docs and didn't have the time to check the source code. But this option is very important.🔍 Example "Recent posts": Sticky posts should show up, but they shouldn't stay on top.
Toolbar vs. Sidebar
tl;dr
Because of other blocks/plugins with similiar behaviour (e. g. Core/Recent posts, WP.Com/Newspack/BlogPosts, Elementor) the complexity (e. g. two steppers and descriptions inside pagination) and power (e. g. Post Type selector) of the paramaters, I think the options of the toolbar should stay in the sidebar.
New UI-Interactions
At the moment, I have the feeling there are way to many new UI interactions:
Complexity
Often toolbar settings are used for visual changes (e. g. bold, italic, text-align, image position) or for simple actions (add new row in tables, add link etc.). In my opinion many of those options are far away from being self-explanatory and simple, e. g. sticky posts (see above), offset, pagination or the technical term "post types". To support the users, I think they definetely need good and verbal descriptions. Furthermore, I really like the icons in the toolbar, but they are very tiny and e. g. the
10/0icon is not self-explanatory enough. I think verbal descriptions and labels would fit the complexity of this block a lot more than icons – and therefore I think the sidebar is perfect.Comparison to other blocks/plugins
I had a look on the
Recent Posts Block, theNewspack Posts Block(thanks @mapk for bringing this in!) and ElementorPosts widget. All of them e. g. have the option for changing the amount of posts showing up, in Elementor you even have the possibility to select post types. All of them have those options in the sidebar. I think it is for good reason: You need way less clicks to change those settings and you can directly see all options at once.mapk commentedon Oct 14, 2020
From a design perspective, I did add those 3 options in a dropdown. Here's how I imagine the various display settings working from the toolbar. Icons would most likely need further iterations.
Post type
Each post type would be identified with an icon, and if none provided, we'd have a generic one for it.
Number of posts / Offset
This icon would change to reflect the numbers entered by the user.
Sort order
Pagination
I know there are conversations around adding more than one pagination block to the query, so by toggling this "on" would add a pagination block to the bottom (most common position) and also allow the Pagination block to show as a child block to add elsewhere within the query too.
Sticky posts
I've included the 3 options as suggested by @mariohamann.
ItsJonQ commentedon Oct 14, 2020
Perhaps I may be overthinking things, but I think the designs may not accommodate more complex WP setups.
(But maybe those folks aren't the target users?)
What I mean by that would be folks with several custom taxonomies beyond Categories and Tags.
I think it gets trickier when taxonomy values are combined, like:
category:Apple,tag:phone,tag:budget,media_type:video,editorial_type:review(just making up values above)
With the sidebar UI, we'd need to have 1 input per taxonomy.
(Not sure how it would work in the Toolbar, especially if values need to be combined).
That being said, I'm not opposed to anything. Just thoughts and observations from my side :)
For the Toolbar, I notice that it's showing custom icons for the Post Types.
I haven't looked into it, but I'm not sure how compatible the data from the REST API is with the editor (as far as icons are concerned, especially custom ones).
I have another question! Would the Query block support custom fields? 😱
If so, that makes it trickier considering the keys and values can be anything 🙈
(Not impossible. The UI just needs to accommodate the flexible nature of it :))
mapk commentedon Oct 14, 2020
Thanks, @mariohamann! When I was exploring more robust filters, mixing the filters in the sidebar with the display settings was overwhelming. Now with more simplified filters, it might be okay to bring some non-essential settings back to the sidebar like sticky posts. It's good to keep these Gutenberg "best practices" in mind for informing the design.
So with that in mind...
I think the Post Type is an important setting as well! It determines a lot of the other settings that can be used. Does moving it to the sidebar make it less important? Keeping it in the toolbar does give it more importance, but it's also a setting that once set is probably not often returned to.
We might be able to provide descriptions in the dropdowns if needed.
Icons aren't great at expressing changes and reflecting settings especially if they are new icons that users aren't familiar with. Moving it all to the sidebar seems to make the sidebar overwhelming and lessen importance of many values. Maybe post types should just be words as you suggested?
@ItsJonQ, thanks for chiming in!
This is correct. I'm not all that familiar with taxonomies, or how often people have multiple taxonomies to choose from. Is this a common thing that could wind up showing 5-10 different taxonomies?
This is correct. @ntsekouras has raised this issue as well. It's where I'd like to get to, but if it can't be achieved with the API, it will need to be displayed differently. Maybe just using words here instead of icons as @mariohamann suggested might work well.
Great question. I not sure myself.
mariohamann commentedon Oct 14, 2020
@ItsJonQ I think this block is perfect to overthink things (and needs it). 😄
Two inputs. We need to seperate "Include" and "exclude" (e. g. including
category:appleand excludingcategory:restricted). Here is an old draft we discussed.I think the way @mapk shows above showing the main taxonomies (cateogry and tags) may be a very good one (as it may meet the expectations of about 98% of blogger...). And we could add "Advanced filters" with the Query Builder for the sophisticated rest of us. :) This would be inline with WP_Query where you can access those main taxonomies per default with
cat(link) andtag(link)– and for the rest you need a more complextax_query(link).Custom fields: This would be just lovely. I think REST API can already handle them.
annezazu commentedon Apr 22, 2021
As part of the fifth call for testing for the FSE, the experience around what lives in the toolbar vs the block's sidebar was mentioned as being quite confusing:
EDITED TO ADD: This came up during the seventh call for testing as well as a point of confusion:
Currently, there is a lot of needing to jump around to both sets of settings. For example, you might want the block to display a certain category but only 3 posts from that category. To do that, you have to interact with the block sidebar settings first to set the category before then using the block toolbar to select the number of visible posts.
mariohamann commentedon Apr 23, 2021
As I reasoned in detail in #25198 (comment) I still think it's much more intuitive to put every setting into the sidebar. Querying is complex, the block is complex, therefore hiding settings behind unfamiliar icons and distributing them across different places reduces usability.
(That's why I didn't use the toolbar in my prototypes.)
annezazu commentedon Oct 18, 2021
More feedback around this experience has come up in the tenth call for testing for the FSE Outreach Program. This seems to be a repeated point of confusion:
ntsekouras commentedon Oct 19, 2021
@jameskoster any design input for this? 🙇
jasmussen commentedon Oct 19, 2021
There will likely be cases in the future where we have a particular control available both in the inspector, and in the block toolbar. I'm thinking for example background color options for the Cover block. Given that as a pattern, it could make sense to visualize what it might look like if a query options panel held these options, with the same contents of the panel duplicated in the block toolbar flyout.
jameskoster commentedon Oct 19, 2021
Swimming the sea of Design Tools, I can't shake the idea that we might use that UX to create a query builder of sorts:
https://jameskoster.design/2021/10/07/concept-creating-a-query-builder-inspired-by-design-tools/
I know this is a much bigger thing, but I think we should be careful about arbitrarily moving things around without a clearer vision for where we want this block (and it's variations) to go. That said – and to Joen's point – if we wanted to put these settings in the Inspector in addition to the toolbar, I think that would be fine.
Edit: I opened a discussion for the query builder idea: #35760
davewhitley commentedon May 1, 2024
To echo the past few comments on this post:
Absolutely! It would be great to explore an advanced query builder, but I think the QL controls in the toolbar should at least be duplicated in the sidebar. That's where I first looked for those settings, and I didn't find them until several days later. I can imagine users might not ever find those controls if they aren't looking for them in the block toolbar.
I very much think of the block toolbar as an inline settings thing, like text appearance, paragraph alignment, width alignment, etc.
ntsekouras commentedon Oct 25, 2024
Query Loop controls have change much since this issue was created. Let's close it.