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

Query block: Nicer URLs for paged query. #32531

Open
alaczek opened this issue Jun 9, 2021 · 13 comments
Open

Query block: Nicer URLs for paged query. #32531

alaczek opened this issue Jun 9, 2021 · 13 comments
Labels
[Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block [Type] Enhancement A suggestion for improvement.

Comments

@alaczek
Copy link

alaczek commented Jun 9, 2021

I noticed that URLs of a paged query results have a structure looking something like this: https://mylocal.test/test-page/?query-7-page=2. Would it be possible for the link to look nicer and be more easily readable?

Steps to replicate:

  1. On a site with a few blog posts, create a new page and add a Query block.
  2. Configure the Query block so that not all of the posts would be shown, and add a Query Pagination block.
  3. Publish the page and preview. Scroll down to the pagination section and go to page 2.
  4. Note the URL in the address bar.
@ntsekouras
Copy link
Contributor

👋 - what do you propose as nicer URL?

Currently the query-7-page=2 parts define:

  1. query - the block name as there is no special labeling/naming per Query block instance
  2. 7 - a unique numeric id per block instance
  3. page=2 - the page number

We need all the above info (page and query identifier) because this way multiple Query Loop blocks are supported in the same page, with their own pagination.

@ntsekouras ntsekouras added the [Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block label Jun 9, 2021
@alaczek
Copy link
Author

alaczek commented Jun 15, 2021

I don't have a specific structure in mind. I was expecting something that would align with the custom permalinks settings.

image

If we're giving users these settings, it makes sense they should be applied universally.

@carlomanf
Copy link

We need all the above info (page and query identifier) because this way multiple Query Loop blocks are supported in the same page, with their own pagination.

The ugly link may be unavoidable for the scenario of secondary loops, but it would make sense to defer to the permalinks settings (e.g. /page/2/) for loops that have the "inherit" setting turned on.

@ntsekouras
Copy link
Contributor

but it would make sense to defer to the permalinks settings (e.g. /page/2/) for loops that have the "inherit" setting turned on.

It actually does that. If a Query Loop inherits from the global query and pretty links are enabled, the pagination produces links like this: http://localhost:8888/page/5/?query-10-page=3.

page/5/ is from the inherit query and query-10-page=3 is for a custom query.

@kathrynwp
Copy link

If we're giving users these settings, it makes sense they should be applied universally.

Adding a big plus-one for hiding the query string generated by this block. Users have been asking how to do it, and are confused by not having pretty permalinks there, when they work as expected everywhere else outside of this one block. A URL structure that matches how this is done in classic themes would be just fine.

@bph
Copy link
Contributor

bph commented Jan 9, 2023

I wonder if this wouldn't need to be implemented via the permalink component on the backend
@SergeyBiryukov If at all, how would something like this make it into a new 'permalink' setting? Any additional thoughts?

@bfintal
Copy link
Contributor

bfintal commented Apr 28, 2023

Suggestion: we can add an option on the pagination block itself to change the permalink query var for the block.

The components of the query var as pointed out by @ntsekouras are all needed, but only so that the query loop and page can be detected from the URL and so it can be pin-pointed which loop we're trying to query the next for. But if you can specify the query var for the pagination block, then you won't need any kind of detection since you'll be sure it's unique.

@Thelmachido
Copy link

Another GitHub-related issue might be a duplicate #48251

@Thelmachido
Copy link

Another request in forums similar to this:

My WordPress 6.2 Twenty Twenty Three theme home page includes a query loop for blog posts (six posts at a time ) and pagination. When ‘older posts’ are clicked, the url changes from [https://domain] to [https://domain/?query-0-page=2] and so on. When you click on newer posts to get back to the home page instead of showing [https://domain] it shows [https://domain/?query-0-page=1]. Is this normal? And will the pages with the ?query… extensions cause problems in Google crawling and indexing? For example, the home page [https://domain] now has another url: [https://domain/?query-0-page=1].

Forum issue: https://wordpress.org/support/topic/pagination-493/

@sybrew
Copy link

sybrew commented Nov 18, 2023

When creating this block, it creates custom queries and replaces ALL links with ?query-* on the page.

These pages are not correctly registered with the WordPress Query and Rewrite APIs.

Some plugins, like Yoast SEO, will blindly insert those links and bring down sites from Google.
Others that rely on official APIs like The SEO Framework cannot acknowledge their registration via proper APIs.

Background: https://wordpress.org/support/topic/query-pages-getting-indexed/#post-17211606.

This breaks SEO and brings down sites when the block is used -- but perhaps even when it's not.

image

I urge you to reconsider this block's foundations or even its existence.

@priethor priethor added this to Polish Jul 10, 2024
@priethor priethor moved this to Needs decision in Polish Jul 10, 2024
@jeflopodev
Copy link

jeflopodev commented Nov 11, 2024

Using WP 6.7 rc4 and Query Type Default I get paginated urls like /?paged=2 😢 (iirc in previous versions of WordPress we had /page/2 urls while inheriting) and when using the Custom query type I get paginated urls like /?query-0-page=2

Sadge...

I'm not using Plain permalink structure so I was not expecting urls using query string params.

I'd wish pages would be paginated like /page/2 instead

@ntsekouras
Copy link
Contributor

Using WP 6.7 rc4 and Query Type Default I get paginated urls like /?paged=2 😢 (iirc in previous versions of WordPress we had /page/2 urls while inheriting)

@jeflopodev I couldn't reproduce that in 6.6 and additionally blocks like Page Numbers that render these links haven't had bigger updates for more than 9 months.

I'm not using Plain permalink structure so I was not expecting urls using query string params.

Are you using some kind of Custom Structure for permalinks that could have affected that? If yes, can you share more details?

Finally noting that for custom Query Loop blocks we never had urls like page/2 etc. and that's what being discussed in this issue.

@jeflopodev
Copy link

jeflopodev commented Nov 17, 2024

@jeflopodev I couldn't reproduce that in 6.6 and additionally blocks like Page Numbers that render these links haven't had bigger updates for more than 9 months.

Hi @ntsekouras
I have now tried the playground with 6.7 and the TT5 theme and I see urls like /posts-page/page/2/ when it's inherited (default), and /posts-page/?query-6-page=2 when it's set to custom.

So I'm no longer having the issue I had (/?paged=2) I guess.

Are you using some kind of Custom Structure for permalinks that could have affected that? If yes, can you share more details?

I was using "Post name" permalink structure

Finally noting that for custom Query Loop blocks we never had urls like page/2 etc. and that's what being discussed in this issue.

I really dislike WP using query string params for custom query loops. IMHumbleO this should be handled internally and transparently for the end user, so the URLs could still be /page/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block [Type] Enhancement A suggestion for improvement.
Projects
Status: Needs decision
Development

No branches or pull requests

9 participants