Home API Display a Random Insult on Your Website with PHP or WordPress Shortcode

Display a Random Insult on Your Website with PHP or WordPress Shortcode

WordPress Insults Plugin

Insults has to be one of the most pointless plugins in the WordPress repository. It was the first plugin we ever submitted to WP and was done so – like a few others – just to test the WordPress waters and get a feel for how their approval process worked. The plugin will retrieve an ‘insult’ from a database of thousands and return it. Simple. Like all plugins, it’ll find its place somewhere.

This post will show you how to access a random insult via our API with shortcode, PHP, or with our WordPress plugin.

The Results

The result of this function will render something like this on your website:

“You are living proof of reincarnation. No one could possibly get to be so stupid in just one lifetime.“

Cheesy, we know.

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.


Insert the shortcode of [insult] wherever it is you want your insult to be rendered. The default code will cache the text for 1 hours (3600 seconds) but you can get them as often as every 6 minutes. We cache the text locally on our end for 5 minutes.

PHP Function

Used outside of WordPress, the following PHP function may be used. It requires the use of Simple Cache.


The plugin version is hosted in the WordPress plugin repository.

Plugin Title: INSULTS Author: beliefmedia
Description: Insults is an extremely simple plugin that’ll generate a random insult on your website every hour.
Download (downloaded 476 times) | Plugin Page

Title: Display a Random Insult
Description: Display a Random Insult on Your Website with PHP or WordPress Shortcode.
Download: Shortcode (V0.2) | PHP Code (V0.2) | Plugin Page

■ ■ ■

Interested in WordPress and Web Design? Subscribe to our list and we'll send you subscriber-only tools and plugins

Short URL for this post: http://shor.tt/19nT