I am trying to: Create a button so that when clicked, it refreshes a Toolset View I created that shows 2 random posts.
Link to a page where the issue can be seen: hidden link
I expected to see: Since I set View to Order by Random and only display 2 posts, that it would return to NEW random posts on a page reload.
Instead, I got: it just loads the same 2 posts that were previously shown before the page was reloaded. (I've tried putting a "submit" and a "reset" button, each did not work for me either.
Hello,
Thanks for details, I can see the problem in your website.
Here are what I found:
Q1) When I click the "Roll The Dice" button, I see some JS error in my browser console window, for example:
Uncaught TypeError: Cannot read property 'querySelectorAll' of undefined
I suggest you try to fix those JS errors first.
Q2) And the problem you mentioned above persists when I refresh the browser by pressing F5 key.
Please check these:
1) Follow our document to display the Views shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view
For example:
[wpv-view name="My amazing custom post list"]
Without "order" or "orderby" attributes
2) It might be a cache problem, please deactivate all other plugins, and switch to wordpress default theme 2019, and test again
Hi Luo, I created another page where we can troubleshoot this: hidden link
I tried the adding the shortcode, both with and without cached="off". When I refresh the page, the same 2 posts that were shown previously are being shown. I'm hoping that the view will reload 2 new random posts on every page refresh.
In terms of the "Uncaught TypeError: Cannot read property 'querySelectorAll' of undefined", I believe those to be unrelated because that error appears when you click anywhere on our screen. Disabling plugins and changing the theme is not really an option for us.
How else might we get this functionality to work? Is it expected that if ordering by "random", that every time the page refreshes, new random posts will be displayed?
Thanks for the confirmation, I have tried the same setting in my localhost with a fresh wordpress installation, it works fine, when I refresh the page, it display other random posts.
So the problem is abnormal, there might be other compatibility problem of your website, as I mentioned above:
Please try these:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2019, and test again
2) If the problem is fixed, you can activate other plugins/theme one by one, try to locate the problem plugin/theme
If you need assistance to locate the problem, please provide a copy of your website(you can put the duplicator package in your own google drive disk, and share the link in below private message box).
Thanks for the details, I am downloading the files, will update here if there is anything found.
The files you provided above is not valid to duplicate the problem, I got a lots of MySQL errors when import those SQL files.
Have you tried as I mentioned above to locate the problem plugin/theme:
https://toolset.com/forums/topic/load-random-posts-on-page-refresh/#post-1361019
deactivate all other plugins, and switch to wordpress default theme 2019, and test again
You can also provide a test site with the same problem, provide website credentials and FTP access in below private message box, I need to deactivate plugins/theme in it, thanks
Figured it out by replicating the pagination button as a "refresh" button. Accomplishes the same goal to the user. The plugins that were interfering were necessary for the rest of the site to function, so I wasn't able to do that as a solution.