A few years ago we toyed around with the idea of submitting a few plugins to the WordPress repository. Most of them were very basic simply so we could wrap our heads around the way they the WP system worked. One of the first plugins we submitted was QOTZ - a really simple plugin that'd do nothing except render a random quote on your WP website. The plugin is partnered with an unmonitored website, Twitter account , and Facebook page (all displaying the quotes as images rather than text).
A lot of what we worked on a few years ago included an XML API. While we thought XML data was appropriate at the time (mainly because it was browser-readable), history has since educated us on our wayward ways. As we rebuild a number of our websites, any API will return JSON data almost exclusively - now sensibly our norm. This post will essentially reproduce what we once shared on another site: how to render a random quote in your website with shortcode (using our newer, improved, faster, and more reliable API). The plugin update will follow.
If you're a client and have an API key, check the platform for expanded usage (such as text search, branded image quotes, quotes by author, and paginated results).
The result is as advertised: a random quote. Shortcode of
[qotz] will return the following (bolding and blockquote is mine):
"It is truer to say that martyrs create faith more than faith creates martyrs." — Miguel de Unamuno
The quote is cached on your end for 15 minutes. That ensures you don't retrieve the same cached quote on our end.
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.
Used outside of WordPress the following function can be used. It requires that you include Simple Cache.
- Most of what's quoted on the Internet is what we wanted people to say, not what they actually said. Einstein and Marilyn Monroe are probably two of the hardest hit by distorted or fake attribution. However, short quotes are often a paraphrased sentiment, giving them a certain truth.
- The quote can obviously be formatted with HTML to your liking.
- Clients have access to a huge database of quotes in our library that can all be manufactured into custom images. Once created, they can be sent to social in a number of ways.
- Despite showing a small number of downloads, we will build upon this plugin to return movie quotes and other information.