Title: Random File
Author: Scott Reilly
Published: <strong>ডিচেম্বৰ 21, 2004</strong>
Last modified: এপ্ৰিল 8, 2025

---

প্লাগিনৰ সন্ধান কৰক

![](https://ps.w.org/random-file/assets/banner-772x250.png?rev=837026)

![](https://ps.w.org/random-file/assets/icon-128x128.png?rev=1091134)

# Random File

 [Scott Reilly](https://profiles.wordpress.org/coffee2code/)-ৰ দ্বাৰা

[ডাউনল’ড কৰক](https://downloads.wordpress.org/plugin/random-file.2.0.1.zip)

 * [বিশদ বিৱৰণ](https://as.wordpress.org/plugins/random-file/#description)
 * [পৰ্য্যালোচনা](https://as.wordpress.org/plugins/random-file/#reviews)
 *  [ইনষ্টলেশ্যন](https://as.wordpress.org/plugins/random-file/#installation)
 * [বিকাশ](https://as.wordpress.org/plugins/random-file/#developers)

 [সাহায্য](https://wordpress.org/support/plugin/random-file/)

## বৰ্ণনা

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 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](https://coffee2code.com/wp-plugins/random-file/) | [Plugin Directory Page](https://wordpress.org/plugins/random-file/)
| [GitHub](https://github.com/coffee2code/random-file/) | [Author Homepage](https://coffee2code.com)

### Developer Documentation

Developer documentation can be found in [DEVELOPER-DOCS.md](https://github.com/coffee2code/random-file/blob/master/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.

These are the hooks provided by the plugin:

 * `c2c_random_file` : Filter 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` : Filter 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.

## ইনষ্টলেশ্যন

 1. Install via the built-in WordPress plugin installer. Or download and unzip `random-
    file.zip` inside the plugins directory for your site (typically `wp-content/plugins/`)
 2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
 3. Make use of the `c2c_random_file()` or `c2c_random_files()` template function in
    your code or template (see examples below).

## সঘনাই উত্থাপিত প্ৰশ্ন

### Does this plugin do dynamic random rotation within a loaded page (i.e. randomly rotating images within a loaded page)?

No. This plugin only selects a random file when the page is loaded. Once loaded,
it does not currently add any dynamic functionality to automatically retrieve another
random file on its own.

### Does this plugin include unit tests?

Yes. The tests are not packaged in the release .zip file or included in plugins.
svn.wordpress.org, but can be found in the [plugin’s GitHub repository](https://github.com/coffee2code/random-file/).

## পৰ্য্যালোচনা

এই প্লাগিনৰ বাবে কোনো পৰ্য্যালোচনা নাই।

## অৱদানকাৰী আৰু বিকাশকাৰীসকল

“Random File” হৈছে মুক্ত উৎসৰ ছফ্টৱেৰ। এইসকল লোকে এই প্লাগিনত অৱদান আগবঢ়াইছে।

অৱদানকাৰীসকল

 *   [ Scott Reilly ](https://profiles.wordpress.org/coffee2code/)

[আপোনাৰ ভাষাত “Random File” অনুবাদ কৰক।](https://translate.wordpress.org/projects/wp-plugins/random-file)

### বিকাশৰ প্ৰতি আগ্ৰহী?

[ক’ড ব্ৰাউজ কৰক](https://plugins.trac.wordpress.org/browser/random-file/), [SVN ৰিপজিটৰী](https://plugins.svn.wordpress.org/random-file/)
চাওক নাইবা [RSS](https://plugins.trac.wordpress.org/log/random-file/?limit=100&mode=stop_on_copy&format=rss)-
দ্বাৰা [বিকাশৰ পঞ্জী](https://plugins.trac.wordpress.org/log/random-file/) ছাবস্ক্ৰাইব
কৰক।

## সলনি-পঞ্জী

#### 2.0.1 (2025-04-08)

 * Fix: Fix typos in documentation
 * Change: Note compatibility through WP 6.8+
 * Change: Update copyright date (2025)
 * Unit tests:
    - Change: Switch uses of `assertRegExp()` to `assertMatchesRegularExpression()`
      for future PHPUnit 10 compatibility
    - Change: Explicitly define return type for overridden method

#### 2.0 (2024-08-13)

Highlights:

This minor update features improved randomization of file selection, adds support
for the extensions argument to be an array, notes compatibility through WP 6.6+,
removes unit tests from release packaging, updates copyright date (2024), and other
code improvements and minor changes.

Details:

 * Change: Switch to using `wp_rand()` for more reliable randomization
 * Change: Allow `$extensions` argument to also accept an array of extensions
 * Change: Strip surrounding whitespace and leading periods from provided extensions
 * Change: Explicitly return false if no file could be found
 * Change: Switch to use a switch statement, which is more concise
 * Change: Use cleaner `sprintf()` approach to outputting markup
 * Hardening: Escape text shown via ‘hyperlink’ output (though it’s never anything
   other than plaintext)
 * Change: Note compatibility through WP 6.6+
 * Change: Update copyright date (2024)
 * Change: Tweak filter descriptions in `readme.txt`
 * New: Add `.gitignore` file
 * Change: Remove development and testing-related files from release packaging
 * Unit tests:
    - Hardening: Prevent direct web access to `bootstrap.php`
    - Allow tests to run against current versions of WordPress
    - New: Add more unit tests
    - New: Add `composer.json` for PHPUnit Polyfill dependency
    - Change: In bootstrap, store path to plugin directory in a constant
    - Change: Rename a test

#### 1.8.12 (2023-05-21)

 * New: Add DEVELOPER-DOCS.md and move hooks documentation into it
 * Change: Note compatibility through WP 6.3+
 * Change: Update copyright date (2023)

_Full changelog is available in [CHANGELOG.md](https://github.com/coffee2code/random-file/blob/master/CHANGELOG.md)._

## মেটা

 *  **2.0.1** সংস্কৰণ
 *  **1 বছৰ আগত** শেষবাৰ আপডে’ট হৈছিল
 *  সক্ৰিয় ইনষ্টলেশ্যন **90+**
 *  WordPress-ৰ সংস্কৰণ ** 2.8 বা তাতকৈ ওপৰৰ **
 *  ইমানলৈকে পৰীক্ষা কৰা হৈছে **6.8.6**
 *  ভাষা
 * [English (US)](https://wordpress.org/plugins/random-file/)
 * [coffee2code](https://as.wordpress.org/plugins/tags/coffee2code/)[file](https://as.wordpress.org/plugins/tags/file/)
   [files](https://as.wordpress.org/plugins/tags/files/)[random](https://as.wordpress.org/plugins/tags/random/)
   [randomize](https://as.wordpress.org/plugins/tags/randomize/)
 *  টেগবোৰ
 *  [উচ্চখাপৰ ভিউ](https://as.wordpress.org/plugins/random-file/advanced/)

## ৰে’টিংবোৰ

 5টাৰ ভিতৰত 5টা তৰা।

 *  [  1 5-star review     ](https://wordpress.org/support/plugin/random-file/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/random-file/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/random-file/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/random-file/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/random-file/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/random-file/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/random-file/reviews/)

## অৱদানকাৰীসকল

 *   [ Scott Reilly ](https://profiles.wordpress.org/coffee2code/)

## সাহায্য

কিবা ক’বলগীয়া আছে? সহায় লাগে?

 [সাহায্যৰ ফ’ৰাম চাওক](https://wordpress.org/support/plugin/random-file/)

## দান কৰক

আপুনি এই প্লাগিনৰ উন্নতিৰ প্ৰতি সাহায্য আগবঢ়াব বিচাৰেনে?

 [ এই প্লাগিনক অনুদান দিয়ক ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ARCFJ9TX3522)