Skip to content
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

Term Query Loop Block #49094

Open
Tracked by #62680
tomjn opened this issue Mar 15, 2023 · 19 comments
Open
Tracked by #62680

Term Query Loop Block #49094

tomjn opened this issue Mar 15, 2023 · 19 comments
Labels
New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.

Comments

@tomjn
Copy link
Contributor

tomjn commented Mar 15, 2023

What problem does this address?

Currently you can create a tag cloud, and there's a post term list, but these options are limited, and come in 2 versions ( one for the current post, and one that's just general ). If I need to build anything that deviates from this I'm forced to build a new block.

E.g. if I want to display terms with their term descriptions, or add a graphic next to each tag, sort terms into columns, etc, I can't do that with core blocks. Or even spread terms out in a row the same way a group/row block can.

e.g. creating this type of category list automatically is not possible with the core blocks:

Politics

News articles about politics

Sports

The latest sports news

What is your proposed solution?

Instead, A term query block similar to the post query block would be very useful, with term title, term description etc blocks.

This way the existing core blocks could be constructed in any shape form or layout by the users choice without writing code. E.g. using headings for tags with descriptions, custom term featured image blocks in plugins, adding icons, etc

Variants of the block could be registered for each taxonomy too:

Screenshot 2023-03-15 at 12 32 45

@tomjn tomjn changed the title Term Query Block Mar 15, 2023
@ndiego ndiego added the [Type] Enhancement A suggestion for improvement. label Mar 15, 2023
@kathrynwp kathrynwp added the New Block Suggestion for a new block label Mar 15, 2023
@MaggieCabrera
Copy link
Contributor

+1 on this. It's a very common pattern for themes that we can't really work around right now. A good example is the section By Topic on Blue Note, a community theme currently in development: WordPress/community-themes#5

@scruffian
Copy link
Contributor

The query look actually allows for this already. You can filter the query loop based on a tag or a category:
Screenshot 2023-06-08 at 14 35 36

@tomjn
Copy link
Contributor Author

tomjn commented Jun 8, 2023

@scruffian you've misunderstood, this issue is not about displaying posts in a term, it's about displaying the terms themselves!

E.g. it would not produce a post list, it could produce a tag list like this:

Screenshot 2023-06-08 at 14 56 20

Or more complex items, e.g. a heading with a read more button underneath with a term description

@scruffian
Copy link
Contributor

Ah thanks, I thought I must be missing something!

@huubl
Copy link
Contributor

huubl commented Jul 12, 2023

+1 this! Are there any updates/decisions made about adding this new block?

@scruffian
Copy link
Contributor

+1 this! Are there any updates/decisions made about adding this new block?

We want it, we just need someone to build it!

@tomjn
Copy link
Contributor Author

tomjn commented Jul 21, 2023

Noting that this will need scoping out by an engineer to figure out exactly what needs to be done, it's not as simple as asking for it to be done then someone doing it.

For example, issues for at least these blocks would need to be created:

  • Term Loop
    • category and tag variants with the taxonomy preset
    • term template block
    • no terms block
    • term name/title block
    • term description block

People can probably think of more such as a term slug block but these seem to be the MVP, and each of those will require its own issue and dependencies.

I can also see API changes being desirable re: variations. Afterall if you use a category loop you don't expect a term template, you expect a category template, and a category name/title, making those blocks dependent.

There's also the possibility that because the terms are different entities that it might require taxonomy specific blocks be registered or variants for each taxonomy so that they know which entity type to access and can display the right information.

For those versed in agile, this is more like a spike than an implementation ticket, help/contributions needed for specification

@tomjn
Copy link
Contributor Author

tomjn commented Jul 21, 2023

+1 this! Are there any updates/decisions made about adding this new block?

This is pretty straight forward to answer. Unless you see PRs mentioned here then there has been no work done to build this. If you can't see any decision making then that means no decision making took place.

If there were a place were decisions were made related to this that didn't filter down it'd be the public weekly editor meetings, but someone would have to raise it on the agenda, and it's highly unlikely the info wouldn't filter over to here. Unless someone made another issue and that one got traction instead.

@annezazu
Copy link
Contributor

Punting to 6.5 for consideration since we're four weeks away from beta 1.

@annezazu
Copy link
Contributor

Punted for the same reason as before. This is going to take intentional effort to get done so if anyone is interested for 6.6, please speak up!

@skorasaurus
Copy link
Member

skorasaurus commented Mar 1, 2024

I'm working with term meta and terms for the first time in several years (or ever?) and came across this issue while reviewing what capabilities exist in Gutenberg in order to find a block that would display all terms that exist for a particular taxonomy across an entire website.

Even after some research about the current state of such a block; I was a bit confused and found this issue which heavily overlaps with #33302 (This is cross-posted in #33302 as well).

I include some notes in case anyone else has the same issue or is trying to triage this issue:

Categories block - lists all terms that exist for the taxonomy 'category' across an entire website.
In the block inserter and list view, the block is called 'Categories List'
Block markup: <!-- wp:categories /-->
Only can select the 'category' taxonomy

Post Terms block - lists the terms that are assigned for a taxonomy (selected in the attribute field) on a particular post or page
In the block inserter and list view; these blocks are named "Categories" or "tags"
<!-- wp:post-terms {"term":"category"} /--> or
<!-- wp:post-terms {"term":"post_tag"} /-->

If you register a custom taxonomy, a block variation for the post terms block is registered.
It appears in the block inserter and list view as "Name of your taxonomy(s)"

Tag cloud - lists all of the terms that exist for the taxonomy "post_tag" across an entire website.
in the block inserter and list view, the block is called 'Tag Cloud'; displays it in a cloud like format.
Only can select the taxonomies 'category' and 'post_tag'

or

There are a couple existing PRs #58033 & #26555 that modifies the categories block to select any taxonomy and displays all of that taxonomy's terms on the website.

Going forward in the long-term: I think a new flexible block(s) would probably be appropriate as Tom described at #49094 (comment)

There is a separate block under development - https://github.com/mattyza/terms-list-block but I haven't examined it.

@skorasaurus skorasaurus added [Block] Tag Cloud Affects the Tag Cloud Block and removed [Block] Tag Cloud Affects the Tag Cloud Block labels Mar 9, 2024
@aaroncommand
Copy link

@skorasaurus has perfectly described what we and doubtless thousands of other developers need as well - a block that would display all terms which exist for a particular taxonomy. (Ideally with some straightforward way to modify the query being run by that block, so we could filter it by children of a particular term, etc.) It's baffling to me that custom taxonomies are such a fundamental feature of WordPress, people have been asking for some variant of this request for years, and yet resources are being spent to building a real-time multi-user version of Gutenberg or whatever instead of creating this block. For now we are probably just going to hack this up in PHP and punt on the template being block-editor-friendly, since in the old world this is basically just a call to get_terms() that takes two minutes to write.

@tomjn
Copy link
Contributor Author

tomjn commented Apr 17, 2024

@aaroncommand he's only in charge of spending his own personal time that's contributed and volunteered here, there's no corporate decision delaying this from being built or product roadmap that punted this.

For this to move forward what's needed is for an engineer to scope out what has to happen so that others know what to do and where to do it. Building this for a single client/customer is easier than making sure this gets built properly for core as tiny engineering decisions can have huge ramifications.

Any support you can show will help here enormously even if it only answers part of the puzzle

@colorful-tones
Copy link
Member

Hi folks,
We are only one week away from the Beta 1 cut-off date for WordPress 6.6. This issue hasn’t seen any movement in a while, so we (the editor triage leads of the 6.6 release) have decided to remove it from the WordPress 6.6 Editor Tasks project board.

@noisysocks
Copy link
Member

Ran into this while creating a block theme. Definitely a big limitation. There's currently no nice way to create a section like this in a block theme:

Screenshot 2024-06-04 at 14 41 03

Instead of a new block, could Categories and Tags be an option in the Query Loop block's settings? I suppose maybe not since there'd need to be an accompaniment of related inner blocks e.g. Taxonomy Title and Taxonomy Count.

@ntsekouras
Copy link
Contributor

Instead of a new block, could Categories and Tags be an option in the Query Loop block's settings? I suppose maybe not since there'd need to be an accompaniment of related inner blocks e.g. Taxonomy Title and Taxonomy Count.

We cannot use Query Loop. We'd need to update some existing term blocks and add new ones.

@kauaicreative
Copy link

Came across this implementation of a Term query loop - elegant!
https://brickslabs.com/how-to-list-your-posts-divided-by-categories/
Excited for this! 🔥

@tomjn
Copy link
Contributor Author

tomjn commented Jun 29, 2024

@kauaicreative that's using the bricks page builder not Gutenberg

@kauaicreative
Copy link

kauaicreative commented Jun 29, 2024

@kauaicreative that's using the bricks page builder not Gutenberg

Yes, bricks. I have not personally used Bricks - but the implementation may offer some inspiration:

  1. A single Query Block allows one to query either terns or posts e.g. Choose Terms as query Type and Categories as the taxomomy.
  2. It allows for nested query loops which is explained in the referenced tutorial link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.