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

Add Random Order By Dropdown Item #50999

Closed
wants to merge 2 commits into from
Closed

Add Random Order By Dropdown Item #50999

wants to merge 2 commits into from

Conversation

Vrishabhsk
Copy link
Contributor

@Vrishabhsk Vrishabhsk commented May 26, 2023

What?

Why?

How?

Testing Instructions

  1. Create a post or a page
  2. Add the Query Loop Block
  3. Select Start Blank
  4. Select any variation
  5. In the block inspector controls Order by Dropdown Select Random

Testing Instructions for Keyboard

NA

Screenshots or screencast

Screenshot 2023-05-26 at 3 22 21 PM Screenshot 2023-05-26 at 3 22 27 PM Screenshot 2023-05-26 at 3 22 15 PM

@Vrishabhsk Vrishabhsk requested a review from ajitbohra as a code owner May 26, 2023 09:53
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label May 26, 2023
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Vrishabhsk! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Sisanu
Copy link
Contributor

Sisanu commented May 31, 2023

From my experience, using random order in queries comes with performance costs. Also, random sorting makes the pagination irrelevant, as most websites are using the cache, hence the random set will only work for the first user loading the un-cached page.

Additionally, when you load another page (from pagination), the output might fetch the posts already randomly picked on the previous page or some of the posts will never be listed, and that can be very confusing.

What needs are you aiming to solve with random sorting?

@ashrudral
Copy link

What needs are you aiming to solve with random sorting?

Are you seriously asking this question? Forgive me but you are talking like someone who is a web development genius but doesn't know a thing about blogging. All blogs need to have random order of blog post for their readers. If you use alphabetical order or chronological order, users will have difficultly finding posts that they haven't explored before.

As for the same random sorted cache page being served to all users, the cache is frequently automatically purged. It's the closed we can get to how the things should be.

Random sorting is not just a need, it's a desperate need. Which was already met since 10 years ago. Now we the early adopters of WordPress Gutenberg FSE (not developer, but actual bloggers, aka end user of this open source technology) are struggling to have our basic needs met.

@Sisanu
Copy link
Contributor

Sisanu commented Aug 23, 2023

Are you seriously asking this question? Forgive me but you are talking like someone who is a web development genius but doesn't know a thing about blogging.

You seem a bit desperate to get a reaction to your reply :).
What's the point of this phrase, what are you trying to get from this discussion?

Regarding the "desperate need" you are describing, it does not justify the means to solve it like this. We are discussing this feature proposal in the WordPress core technical context. In my opinion, what you would need for your "desperate need" is a custom feature that can solve your need on the client side, not on the server side. As I said in my previous comment, using a server-side solution will not bypass the cache, nor play nice with performance.

@ashrudral
Copy link

ashrudral commented Aug 28, 2023

We are discussing this feature proposal in the WordPress core technical context. In my opinion, what you would need for your "desperate need" is a custom feature that can solve your need on the client side, not on the server side. As I said in my previous comment, using a server-side solution will not bypass the cache, nor play nice with performance.

It has been mentioned that this feature is a part of the core wordpress for last 10 years at least. And it still is. This core wordpress feature has been suppressed by the Gutenberg team.

Cache is automatically purged once a day at least. So it will rotate our posts and show different posts to the readers. If it is sorted by chronological or alphabetical order, then the readers will see the same post till eternity.

With random post sorting along with bypassing cache limitations. At least they will be able to see new posts every day as cache is purged.

So, our choice is limited between same chronological/alphabetical sorted post till eternity or new post order everyday with random sorting (server side with performance issue and cache bypassing every day).

You mentioned a client side solution that we both know doesn't exist as of now.

Whereas the solution of random sorting is been there for a very long time in wordpress. Even before I started blogging and you started developing, this solution was the default way things worked.

@Supaiku
Copy link

Supaiku commented Dec 29, 2023

What is the status of this core functionality?
Is this basically blocked by the development team and should we just hack or add plugins as a work around, or is this something that Gutenburg is going to make possible?

For instance, if it's just not going to happen in Gutenburg, a reasonable solution might be to make a simple plugin that ads only this functionality to Gutenburg for those that need it and undersand the limitations and performance impact. However, if this is something that Gutenburg is willing to integrate, then that wouldn't be needed.

I agree that this is a serious limitation and that even cached randomization is preferable to being limited to only chronological order.:
https://wordpress.org/support/topic/how-can-i-make-a-query-loop-to-display-posts-by-random-order/
#40481
It's clearly an expected need.

It's not clear to me what client vs server-side solutions even mean, any solution is going to run on the server. What people are doing now is hacking the code, or using other plugins for a fundamental feature, and any way it's cut the code runs on the server so...

Perhaps a warning about the limitations would be warranted, but is a very basic function for a blog. Or an option in the settings that enables the function as a "development" or "advanced" setting.

UPDATE: I was able to get random sorting relatively easily, at the expense of losing editability of the block by switching to code mode, changing a setting, and switching back, as described here: https://wordpress.org/support/topic/how-can-i-make-a-query-loop-to-display-posts-by-random-order/
This isn't the worst work around, though it's definitely jenky.

@ddegner
Copy link

ddegner commented Dec 30, 2023

What needs are you aiming to solve with random sorting?

I personally would like a Random order for a loop on my front page that shows links to stories about 3 other photographers that I like. I have category of about 20 photographers I like and want to highlight different ones every time instead of just the most recent, or alphabetically.

I would also like a loop of one single random post from my backlog of photo posts.

You are imagining a loop of all posts on a site, where yes, this could cause a lot of problems with pagination and caching etc. But I think most people would use it to add some variety to a landing page.

@brnhrst brnhrst mentioned this pull request Aug 1, 2024
14 tasks
@Vrishabhsk Vrishabhsk closed this by deleting the head repository Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants