Created
June 6, 2022 19:39
-
-
Save alanef/9dcec4e26263e7dbb4c9a68770106839 to your computer and use it in GitHub Desktop.
Random shuffle front end posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( ! is_admin() ) { // only do on frontend | |
| add_filter( | |
| 'posts_results', | |
| function ( $posts ) { | |
| shuffle( $posts ); // use php random shuffle | |
| return $posts; | |
| }, | |
| 10, | |
| 1 | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment