This code simply creates a duplicate of the native recent posts widget in WordPress which also includes an additional parameter for ordering your recent posts randomly.
Copy the code from the view raw link and paste at the end of your functions file.
You can use any of the WP_Query parameters in this part of the code to extend the widget modification further.
$r = new WP_Query( apply_filters( 'widget_posts_args', array(
'posts_per_page' => $number,
'no_found_rows' => true,
'post_status' => 'publish',
'orderby' => 'rand',
'ignore_sticky_posts' => true
) ) );
Leave a Reply