Missing listings when sorted by random
This topic contains 7 replies, has 3 voices, and was last updated by Stiofan O’Connor 9 years, 8 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
January 3, 2017 at 8:48 pm #336007
I may seem like a broken record with the Random sorting issues, but the Client has lost their patience.
Now one of their paying members is not showing up on random sort (required to be default). I can attest that through multiple paginations, refreshes, and safe browsing. The listing only showed up a single time.
Examples in a private message:
Please advise. I do not want to find a replacement for GeoDirectory. I love everything else that it does.
January 3, 2017 at 8:49 pm #336008This reply has been marked as private.January 4, 2017 at 1:18 am #336117This reply has been marked as private.January 4, 2017 at 4:33 am #336200Multiple people have not been able to find it, on various computers. switching to A_Z and back, or being logged in helps. But this is a directory plug-in and if paying members are not showing up, that is a huge issue.
As for random not being default, it is. When you change the sort, the URL is appended with ?sort_by=post_title_asc so simply refreshing the page keeps the sort order.
January 4, 2017 at 5:55 am #336218This reply has been marked as private.January 4, 2017 at 12:38 pm #336413Random sort and caching are not friends, it seems you are on wp-engine, i doubt that would ever work.
Stiofan
January 24, 2017 at 3:00 am #348314Shit. After much fuss, my client has formally requested a Geodirectery replacement if I cannot resolve this issue in 1 week. I am willing to pay to get this sorted out (no pun intended).
Caching aside, I can disable that.
Can anyone shine some light on integrating this snippet?
<?php session_start(); add_filter( 'posts_orderby', 'randomise_with_pagination' ); function randomise_with_pagination( $orderby ) { if( is_front_page() ) { // Reset seed on load of initial archive page if( ! get_query_var( 'paged' ) || get_query_var( 'paged' ) == 0 || get_query_var( 'paged' ) == 1 ) { if( isset( $_SESSION['seed'] ) ) { unset( $_SESSION['seed'] ); } } // Get seed from session variable if it exists $seed = false; if( isset( $_SESSION['seed'] ) ) { $seed = $_SESSION['seed']; } // Set new seed if none exists if ( ! $seed ) { $seed = rand(); $_SESSION['seed'] = $seed; } // Update ORDER BY clause to use seed $orderby = 'RAND(' . $seed . ')'; } return $orderby; } ?>I’m not sure how to call GD posts to replace if( is_front_page() ) {
Any help will be much appreciated.
Though, the author of this script mentioned:
Anyway – I thought I’d jump in here quickly to let you know that as of WordPress 4.5, that snippet in my post will be unnecessary (although it will still work of course). The reason for this is that in v4.5+ you will be able to specify a seed value for the random ordering from directly within the WP_Query args. So you can set your orderby parameter to look like this: rand(123) (where ‘123’ is your seed value) – that will achieve the same results as the solution in my post, but using much less code. You’ll still need to use the session to store the seed value, but you won’t need to use the posts_orderby filter anymore. Pretty neat!
January 24, 2017 at 12:25 pm #348481Are you still on wp-engine hosting? I don’t believe they even support sessions so again that code snippet would never work on their hosting.
Stiofan
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket