WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Random File

Retrieve the name, path, or link to a randomly chosen file or files in a specified directory.

This plugin provides template tags that allow you to retrieve the name, path (relative or absolute), url, or fully marked-up link to a randomly chosen file or files in a specified directory.

Arguments to the functions permit you to specify limit what file(s) can be randomly selected based on a given set of file extensions. You can also explicitly specify files that should not be randomly selected.

This functionality can be useful for displaying random images/logos or including text from random files onto your site (writing excerpts, multi-line quotes, etc). Other ideas: random ads, random CSS files, random theme template selection.

Notes:

  • If you want to actually display the name of the random file, be sure to 'echo' the results:
<?php echo c2c_random_file( '/random' ); ?>
  • Unless you limit the file search to only include a particular extension (via $extensions argument), all files in the specified $dir will be under consideration for random selection

  • Can be run inside or outside of "the loop"

Links: Plugin Homepage | Plugin Directory Page | Author Homepage

Requires: 2.8 or higher
Compatible up to: 3.8.3
Last Updated: 2014-1-12
Downloads: 18,563

Ratings

4 stars
4.5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,2,2
100,2,2 100,1,1
100,1,1
100,1,1
0,1,0
100,1,1
100,1,1