Random File

Random File Install Statistics

11
100%
Today: 11 Yesterday: 0 All-time: 26,873 downloads
Random File Icon

Try plugin: Random File

We'll create fresh WordPress site with Random File installed. You have 20 minutes to test the plugin after that site we'll be deleted.

Takes ~10 seconds to install.

About Random File

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

1


0


0


0


0

updated: 1 year ago
since: 19 years ago
author: Scott Reilly

Description

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:

  • 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 | GitHub | Author Homepage

Developer Documentation

Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the template tags and hooks provided by the plugin.

As an overview, these are the template tags provided by the plugin:

  • c2c_random_file() : Retrieves the name of a random file from a specified directory and returns information based on the file.
  • c2c_random_files() : Retrieves the name, path, or link to a specified number of randomly chosen files in a specified directory.

Theses are the hooks provided by the plugin:

  • c2c_random_file : Allows use of an alternative approach to safely invoke c2c_random_file() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site.
  • c2c_random_files : Allows use of an alternative approach to safely invoke c2c_random_files() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site.