Random Content Plugin

This plugin retrieves a random post/page/either one of them from your WordPress installation, used in much the same way as the get_posts() WordPress function. The plugin was based off from Gruppo Modulo’s Random Subpages plugin but extended because I needed much more than subpages.


  1. Download the plugin here.
  2. Unzip it somewhere.
  3. Upload ind_random_content.php into your wp-content/plugins directory.
  4. Go to your WordPress Admin Panel > Plugins and activate the plugin.


To use the plugin to show a random post and/or page, you should open up your template file and use the following function:

ind_get_random_content( $arguments );

Possible arguments are:

show (string)
show only posts, or pages, or both
possible values: post | page | all | both
numberposts (integer)
number of posts/pages to return
parentpage (integer)
limits returned pages to subpages of parentpage
categories (integers, separated by commas)
limits returned posts to posts filed under categories found in arguments
exclude (integers, separated by commas)
limits returned posts to posts NOT filed under categories found in arguments

Sample Usage

To use the plugin to get and show one random post from categories with IDs 3, 4, and 5:

$myposts = ind_get_random_content( 'show=post&numberposts=1&categories=3,4,5' );
foreach( $myposts as $post ) {
	setup_postdata( $post ); 
	<p><?php the_content(); ?></p>

Testimonials and Comments

4 comments to “Random Content Plugin”

  1. Neil Graver

    I found this plug in after searching around for ages for a ‘proper’ random posts plugin for wordpress that actually shows the content of the post, so extremely good work for developing one.

    However, I can’t get it working as I believe wordpress 2.3 doesn’t have the post2cat tables called in the plugin code. I tried fiddling around with it, but getting it working is far beyond my capabilities.

    Do you have any plans to release an update?


  2. Angela

    Hi Neil,

    Thanks for your interest in the plugin! I actually am currently working on an update, so you can expect to see it around sometime after the holidays probably, when I can sit back down and finish the update :)

  3. Hjalle

    There is a bug where unpublished posts shows up. Add this to the query-string before “GROUP BY” to fix the issue:

    and post_status = ‘publish’

  4. Karl

    Hi Angela,

    Many thanks for the plugin, I’d been searching for ages for a plugin to randomly display a subpage. Gruppo Modulo’s plugin didn’t work for me on WP 2.7, but yours did and it’s working great – thanks again!

Write a comment

Comment Metadata
Comment entry