WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.32k stars 4.12k forks source link

Query Loop improvements v2 #41405

Open priethor opened 2 years ago

priethor commented 2 years ago

Supersedes #30910

Since the Query Loop block landed back in WordPress 5.8 and even before, numerous feedback and feature requests have been received.

The Query Loop block is such a powerful site-building tool that striking a balance between functionality and usability is critical. Therefore, ensuring optimal insertion flows and editing experience should be prioritized and considered when adding new features.

Also, leveraging block variations to consolidate similar blocks into the Query Loop will increase code reusability while improving those blocks.

High priority

Consolidating block variations

Insertion workflows

Editing experience

Bugs

Normal priority

Layouts

Design & Styling

WP_Query parity, functionality enhancements and other settings

Performance

annezazu commented 2 years ago

Is there any chance the following can be added under editing experience https://github.com/WordPress/gutenberg/issues/25198 Based on FSE Outreach program feedback over the last few years, it's clear that more needs to be done to reimagine the various division of settings and the language used https://github.com/WordPress/gutenberg/issues/31158. This feels similar to the work done recently to improve the layout controls https://github.com/WordPress/gutenberg/pull/41893 For example, it's long been confusing for folks that to control the number of posts that show, you have to change a setting in the block toolbar rather than the sidebar where you pick which posts to display.

padams commented 2 years ago

It would be wonderful if we could add the attachment post type as an option (or really any custom post type or taxonomy for that matter).

ntsekouras commented 2 years ago

It would be wonderful if we could add the attachment post type as an option (or really any custom post type or taxonomy for that matter).

👋 @padams - Query Loop supports custom post types and taxonomies for filtering for a while now. Were you referring to something different than filtering?

Regarding the attachment option, it is explicitly removed from the available options right now as it's a probably rare use case and would add more cognitive load to most users. Is this something you find useful and missing?

padams commented 2 years ago

👋 @padams - Query Loop supports custom post types and taxonomies for filtering for a while now. Were you referring to something different than filtering?

Right. Just not image taxonomies...

Regarding the attachment option, it is explicitly removed from the available options right now as it's a probably rare use case and would add more cognitive load to most users. Is this something you find useful and missing?

Yes. My primary use case for WordPress is a searchable image archive. Being able to do a simple loop of the "latest images" or a loop that pulls the images for a specific custom taxonomy term would eliminate the need for a lot of plugins and custom php templates.

The killer combo IMHO would be for the gallery block to use the query block as a sort of inner block. That would give unprecedented control over galleries and keep the attachment stuff in its lane.

Right now plug-in developers have essentially recreate the gallery block just to change the query it uses.

NicoHood commented 2 years ago

Please also add this one: https://github.com/WordPress/gutenberg/issues/33789 I dont know why it is closed, but it seems not yet working.

bph commented 1 year ago

@NicoHood could you please open a new issue with

NicoHood commented 1 year ago

@bph the issue I've linked describes exactly my issue. I have no idea why it was closed. It seems to be implemented, but not available for me.

t0mtaylor commented 1 year ago

Not sure if this can be looked at also?

change the url of the Pagination block from /?query-8-page=2/ to /page/2/

https://wordpress.org/support/topic/how-to-change-the-url-of-the-pagination-block-from-query-8-page2-to-page-2/

ntsekouras commented 1 year ago

change the url of the Pagination block from /?query-8-page=2/ to /page/2/

This is because we support multiple Query Loop blocks in the same page. So the ones that inherit the query from template do use the above format. But with multiple blocks we can have urls like this: /page/2/?query-10-page=2, as we preserve pagination for all the blocks.

t0mtaylor commented 1 year ago

change the url of the Pagination block from /?query-8-page=2/ to /page/2/

This is because we support multiple Query Loop blocks in the same page. So the ones that inherit the query from template do use the above format. But with multiple blocks we can have urls like this: /page/2/?query-10-page=2, as we preserve pagination for all the blocks.

Ah I see! Thanks @ntsekouras

What about if there is only one query loop block on the page? could we enforce an option so it is percieved as a friendly rewrite url? /page/2/

Does the latest version already support /page/2/?query-10-page=2 the friendly url stem even though it has the additional query string (as mentioned about multiple query loops per page)? If so what are the settings or functions.php snippet to do this?

You can add the rewrite url into the functions.php file, but how do you they update the url behaviour of the pagination links, next and previous, of the query loop block?

add_action( 'init', function() { add_rewrite_rule( '^read-pg/([0-9]+)[/]?$', 'index.php?query-8-page=$matches[1]', 'top' ); } );

ntsekouras commented 1 year ago

What about if there is only one query loop block on the page? could we enforce an option so it is percieved as a friendly rewrite url? /page/2/

I'm not really sure if we could, as the WP core handling for paging could mess with the actual query and the pagination. I don't have much experience with the url rewriting..