A guide to Quote This

Quote This started a small bit of code I started using on my personal blog around 2006. It was just a simple PHP function for displaying a random quote from whatever category I wanted. It has always been one of my favorite scripts, so I figured I'd beef up the functionality a bit and release it as a plugin.

The plugin's basic functionality — displaying a random quote — is essentially the same, but I've made it easier to use by including a shortcode and widget version of it.

I realize there are tons of quote plugins out there, but I'm glad you're taking some time to try this one out. You are welcome to offer suggestions on how to make it better.

How to install the plugin

  1. Uzip the quote-this.zip folder.
  2. Upload the quote-this folder to your /wp-content/plugins directory.
  3. In your WordPress dashboard, head over to the Plugins section.
  4. Activate Quote This.

How to use the plugin

Once you've activated the plugin, you'll have three choices on how to use the plugin:

  1. Using the quote_this() function
  2. Using the [quote-this] shortcode
  3. Using the Quote This widget

Using the quote_this() function

This method of calling the plugin is ideal for your template files (i.e., single.php, index.php, sidebar.php). What we'll be doing is using a PHP function.

A basic example:

<?php if ( function_exists( 'quote_this' ) ) quote_this(); ?>

To input parameters, you may either use function-style parameters (preferred) or query-string-style parameters.

Example with function-style parameters:

<?php if ( function_exists( 'quote_this' ) ) quote_this( array( 'format' => 'p', 'type' => 'film' ) ); ?>

Example with query-string-style parameters:

<?php if ( function_exists( 'quote_this' ) ) quote_this('format=p&type=film'); ?>

Using the [quote-this] shortcode

The [quote-this] shortcode is ideal for adding quotes to your posts and pages from the Write Post/Page screen. It's simple and requires no PHP knowledge.

A basic example

[quote-this]

You may also choose to input some parameters to customize the output.

Example of the shortcode with parameters:

[quote-this type="life" format="blockquote"]

Using the Quote This widget

The Quote This widget is pretty straightforward. Just head over to the Widgets screen while in your WordPress admin and find the widget labeled Quote This.

You'll see several options to customize the output of your widget. These are the plugin parameters, which are explained below. You may also use this widget any number of times.

Parameters

Quote This has a few parameters, which can be accessed through the function call, shortcode, and widget. Here are the defaults:

$defaults = array(
	'type' => 'all',
	'orderby' => 'rand',
	'format' => 'blockquote',
	'separator' => '-',
	'echo' => true,
);
type
Which type of quotes to show.
Possible values: all (default), art, film, friendship, individual, life, literature
orderby
How to order the quote(s) shown.
Possible values: rand (more options will be added in the future)
format
What XHTML element should wrap the quotation.
Possible values: blockquote (default), p
separator
What should be added between the quote and quote author.
Possible values: Anything (default is -)
echo
Whether the quotation should be printed to the screen or returned for use in a function (is not used for the [quote-this] shortcode.)
Possible values: true (default), false

Styling the output of your quotations

Quote This will give you three CSS classes to work with:

  1. quote-this: Class of the element that wraps the quote and quote author.
  2. quote: Class of the element that wraps the actual quote.
  3. quote-author: Class of the element that wraps the quote author.

The future of the Quote This plugin

I have several plans for this plugin in the future. I'd love to add other options, such as the ability to list more than one quote or order the quote(s) however we please. Maybe even the ability to show quotes from a specific author.

The main goal is to add more quotes to the collection. If you have a collection of quotes sitting around, feel free to send me an email with quotes you'd like to see added. We can even add new categories of quotes. Just put any quotes you'd like in a text file and send them to me (include the quote authors, please).

Plugin support

I run a WordPress community called Theme Hybrid, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($25 USD at the time of writing).

I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.

Copyright & license

Cleaner Gallery is licensed under the GNU General Public License, version 2 (GPL).

This plugin is copyrighted to Justin Tadlock.

2006 – 2009 © Justin Tadlock. All rights reserved.