• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Random Recent Posts Widget Code

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
		 ) ) );

Related Posts

  • Modify Native Recent Posts Widget Output Using widget_posts_args Filter

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags