Title: Random Post on Refresh
Author: Micah Wood
Published: <strong>2018 年 3 月 30 日</strong>
Last modified: 2025 年 5 月 25 日

---

搜索插件

![](https://ps.w.org/random-post-on-refresh/assets/icon-256x256.png?rev=3300317)

# Random Post on Refresh

 作者：[Micah Wood](https://profiles.wordpress.org/wpscholar/)

[下载](https://downloads.wordpress.org/plugin/random-post-on-refresh.1.2.3.zip)

 * [详情](https://cn.wordpress.org/plugins/random-post-on-refresh/#description)
 * [评价](https://cn.wordpress.org/plugins/random-post-on-refresh/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/random-post-on-refresh/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/random-post-on-refresh/#developers)

 [支持](https://wordpress.org/support/plugin/random-post-on-refresh/)

## 描述

The **Random Post on Refresh** plugin allows you to randomly display a different
post on every page load.

Using this plugin is simple:

 1. Install the plugin
 2. Activate the plugin
 3. On the page or post where you want to have a random post display, add the `[random_post_on_refresh]`
    shortcode where you want your post to appear.
 4. Save your changes.

#### Features

 * Works with custom post types
 * No settings page, just an easy way for you to add random posts to your site
 * Clean, well written code that won’t bog down your site

## 安装

#### Prerequisites

If you don’t meet the below requirements, I highly recommend you upgrade your WordPress
install or move to a web host
 that supports a more recent version of PHP.

 * Requires WordPress version 6.4 or greater
 * Requires PHP version 7.4 or greater

#### The Easy Way

 1. In your WordPress admin, go to ‘Plugins’ and then click on ‘Add New’.
 2. In the search box, type in ‘Random Post on Refresh’ and hit enter. This plugin 
    should be the first and likely the only result.
 3. Click on the ‘Install’ link.
 4. Once installed, click the ‘Activate this plugin’ link.

#### The Hard Way

 1. Download the .zip file containing the plugin.
 2. Upload the file into your `/wp-content/plugins/` directory and unzip
 3. Find the plugin in the WordPress admin on the ‘Plugins’ page and click ‘Activate’

## 常见问题

The `[random_post_on_refresh]` shortcode supports a few attributes to give you more
control over the results:

 * **author** – Provide an author ID or a comma-separated list of author IDs if 
   you want to limit the random post to one of those authors. Example: `[random_post_on_refresh
   author="1, 11, 14"]`
 * **ids** – Provide a comma-separated list of post IDs to pull random posts from.
   Example: `[random_post_on_refresh ids="19, 87, 113, 997"]`
 * **image_required** – Only applies when the `show` attribute contains `image`.
   This attribute defaults to `true` and will cause WordPress to filter out any 
   posts without images. If set to `false`, then posts with or without images will
   be shown. Example: `[random_post_on_refresh show="title, image" image_required
   ="false"]`
 * **not** – Provide a comma-separated list of post IDs to exclude. Example: `[random_post_on_refresh
   not="3, 456, 876"]`
 * **order** – Can be either ‘asc’ or ‘desc’. Defaults to ‘desc’.
 * **orderby** – Customize how WordPress orders the fetched results. See https://
   developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
 * **post_type** – Provide a post type or a comma-separated list of post types to
   pull from. You must use the internal post type name. Default is `post`. Example:`[
   random_post_on_refresh post_type="page"]`
 * **posts_per_page** – Provide the number of posts to fetch. Defaults to 100. Posts
   are randomly selected from the posts fetched.
 * **search** – Provide a custom search term to limit the random posts returned.
   Example: `[random_post_on_refresh search="relativity"]`
 * **taxonomy** – Provide a custom taxonomy to pull from. Requires the `terms` attribute
   to be set as well. Example: `[random_post_on_refresh taxonomy="post_tag" terms
   ="2,4"]`
 * **terms** – Provide a term ID or comma-separated list of term IDs to limit the
   random posts returned. Requires the `taxonomy` attribute to be set as well. Example:`[
   random_post_on_refresh taxonomy="post_tag" terms="2,4"]`
 * **class** – Provide a custom class name for the wrapping HTML div. Example: `[
   random_post_on_refresh class="my-custom-class"]`
 * **size** – Provide a registered image size to use for image display (optional,
   only takes effect if images are being shown). Example: `[random_post_on_refresh
   size="thumbnail"]`
 * **show** – Provide a comma-separated list of post elements to display. You can
   also use a vertical pipe `|` character instead of a comma to separate items into
   columns. Options are: title, image, excerpt, content. Defaults to `title, image,
   excerpt`. Items will show in the order you provide. Note: If images are shown,
   only posts with featured images will be returned. Example: `[random_post_on_refresh
   show="title, image"]`

Keep in mind that any of these attributes can be combined as needed. Example: `[
random_post_on_refresh author="19" size="full" not="2310"]`. Also, keep in mind 
that the shortcode can be used in text widgets.

## 评价

![](https://secure.gravatar.com/avatar/796b807d306c0108d0ef8c7fcd068792a93739d9351e2a298a5de1c12e41ee22?
s=60&d=retro&r=g)

### 󠀁[Simple Perfection](https://wordpress.org/support/topic/simple-perfection-4/)󠁿

 [mrtoddkennedy](https://profiles.wordpress.org/mrtoddkennedy/) 2025 年 10 月 21
日

Exactly what I was looking for, works perfectly every time, easy to implement!

![](https://secure.gravatar.com/avatar/5c9224b0079a03c0b476f332de5d848040f80a18c97af7f03bae980e776e1dd1?
s=60&d=retro&r=g)

### 󠀁[Works perfectly!](https://wordpress.org/support/topic/works-perfectly-2475/)󠁿

 [Jericho](https://profiles.wordpress.org/jerichomontes/) 2022 年 6 月 13 日 1 回复

Thanks for this plugin! 🙂

![](https://secure.gravatar.com/avatar/09b76a6d337efa172e50621e21a21068d90e727c51aa368101db5af0c888f03b?
s=60&d=retro&r=g)

### 󠀁[Perfect](https://wordpress.org/support/topic/perfect-8278/)󠁿

 [unruly333](https://profiles.wordpress.org/unruly333/) 2021 年 3 月 11 日 1 回复

Feels light weight and does exactly what it says it does.

![](https://secure.gravatar.com/avatar/29507c2bad15bbfd68e731eb7a4a956cab9681efe96e81092694bfdc96baf13a?
s=60&d=retro&r=g)

### 󠀁[super](https://wordpress.org/support/topic/super-2076/)󠁿

 [loupiloop](https://profiles.wordpress.org/loupiloop/) 2021 年 1 月 10 日

thanks for this plugin !

![](https://secure.gravatar.com/avatar/1d11e3caddc7695572a005f74e3ff35b40dc87d1a8da5da26ebd3b4d4ef8877f?
s=60&d=retro&r=g)

### 󠀁[Great plugin!](https://wordpress.org/support/topic/great-plugin-27884/)󠁿

 [jodirogers](https://profiles.wordpress.org/jodirogers/) 2020 年 9 月 17 日 1 回复

Works like a charm, does exactly what I wanted it to do! Thanks Micah!

![](https://secure.gravatar.com/avatar/b4a2184f98e3d34ddfd809dc0428132bb53a7f831ec7461101ca87cc11402e21?
s=60&d=retro&r=g)

### 󠀁[Works great](https://wordpress.org/support/topic/works-great-6815/)󠁿

 [jeffw203](https://profiles.wordpress.org/jeffw203/) 2020 年 5 月 29 日 1 回复

Does exactly what it says it does. Be sure to suppress caching on the pages that
you use it.

 [ 阅读所有6条评价 ](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/)

## 贡献者及开发者

「Random Post on Refresh」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Micah Wood ](https://profiles.wordpress.org/wpscholar/)
 *   [ imzodigital ](https://profiles.wordpress.org/imzodigital/)

「Random Post on Refresh」插件已被翻译至 1 种本地化语言。 感谢[所有译者](https://translate.wordpress.org/projects/wp-plugins/random-post-on-refresh/contributors)
为本插件所做的贡献。

[帮助将「Random Post on Refresh」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/random-post-on-refresh)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/random-post-on-refresh/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/random-post-on-refresh/)，或通过
[RSS](https://plugins.trac.wordpress.org/log/random-post-on-refresh/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/random-post-on-refresh/)。

## 更新日志

#### 1.2.3

 * Allow customization of order and orderby query args.

#### 1.2.2

 * General maintenance
 * Allow customization of posts_per_page query arg

#### 1.2.1

 * General maintenance
 * Allow filtering of query args

#### 1.2

 * Added a shortcode attribute to allow posts without images to be shown when the`
   show` attribute contains `image`.
 * Bug fix for certain strings not being translatable.

#### 1.1.1

 * Fixed bug where post excerpts were being generated incorrectly.

#### 1.1

 * Ensure code meets coding standards.
 * Don’t allow the current post to be selected as the random post.
 * Always return the last 100 matching items and select the random post from one
   of those.
 * Tested in WordPress 5.0

#### 1.0

 * Tested in WordPress version 4.9.2

## 额外信息

 *  版本 **1.2.3**
 *  最后更新：**1 年前**
 *  活跃安装数量 **500+**
 *  WordPress 版本 ** 6.4 或更高版本 **
 *  已测试的最高版本为 **6.8.5**
 *  PHP 版本 ** 7.4 或更高版本 **
 *  语言
 * [Chinese (Taiwan)](https://tw.wordpress.org/plugins/random-post-on-refresh/) 
   和 [English (US)](https://wordpress.org/plugins/random-post-on-refresh/).
 *  [翻译成简体中文](https://translate.wordpress.org/projects/wp-plugins/random-post-on-refresh)
 * 标签
 * [different post](https://cn.wordpress.org/plugins/tags/different-post/)[post rotation](https://cn.wordpress.org/plugins/tags/post-rotation/)
   [random post](https://cn.wordpress.org/plugins/tags/random-post/)
 *  [高级视图](https://cn.wordpress.org/plugins/random-post-on-refresh/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  6 条 5 星评价     ](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/?filter=1)

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

[查看全部评论](https://wordpress.org/support/plugin/random-post-on-refresh/reviews/)

## 贡献者

 *   [ Micah Wood ](https://profiles.wordpress.org/wpscholar/)
 *   [ imzodigital ](https://profiles.wordpress.org/imzodigital/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/random-post-on-refresh/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://www.paypal.me/wpscholar)