RandomQuotr
Back to my WordPress Plugins page
Current version: 1.0
Revision History:
0.1 – made within the functions.php file of the theme.
1.0 – created the plugin, cleaned some things up
TODO
- Make the admin panel sexier.
Synopsis
In one of my older site layouts, I had a random quote displaying at the top of the page. The original logic was based very much on the Hello Dolly plugin that comes shipped with WordPress. Even though I no longer use the function within my layout, I still had the code and I felt that with a little revision, this could be a psudo-useful plugin.
So one morning I did exactly that. RandomQuotr was born, and with it came the ability to store all of the quotes within the WordPress database, as opposed to the PHP array that it started out as. Some more functionality was added to allow the selection of specific quotes.
That’s pretty much it!
How to use
To get a random quote:
<?php random_quote() ?>.
You can also use <?php $quote = get_random_quote(); ?>
To get a specific quote:
<?php target_quote($quoteNumber) ?> where $quoteNumber is the quote line.
You can also use <?php $quote = get_target_quote($quoteNumber); ?>.
e.g. target_quote(3) will return the 3rd quote.
Note: target_quote will return null when:
- There are no quotes available.
- A number less than one is passed to it (the list starts at 1, not 0).
- A number greater than the total amount of quotes is passed: 100, when there are only 20 quotes.
- A non-numeric value is passed: “twenty”. Note that “33″ WILL work.
