If you look at the top of this page you’ll see that there is a short quip displayed in my header. Every time you visit any page, it changes. I have about fifteen little quotes in my database and they’re set to display randomly with each refresh of the page. I wrote a plugin which makes it easy to add to this functionality to your WordPress site.
For the longest time I’ve been using a plugin that I hacked together the day I first installed WordPress. When you install the blogging engine you get by default the first plugin, “Hello, Dolly”, which was written by Matt Mullenweg, the creator of WordPress. The “Hello, Dolly” plugin displays a random line from the song of the same name in your WordPress Administration Panel window. I just modified the code for that so that I could use my own quotes instead of the song’s lyrics, and I changed it so that the quote appeared on my site instead of in the control panel. It worked perfectly but it was a pain to manage. Any time I wanted to change a quote or add a new one, I was forced to edit the code of the plugin file. That is seriously inefficient.
I knew that to make it simpler I’d have to build a real plugin that stored the pithy quotes in a database table and made it easy to update them right from the WordPress control panel. So that’s what I did. I published the plugin to the WordPress Plugin Repository so anyone can use it.
In your WordPress installation click on the “Plugins” tab and then “Add New”. That will take you to the Repository. If you search by author “dvg”, you’ll find the “David’s Pithy Quotes” plugin and you can install it from there. Click the “Settings” tab after it’s installed and activated and that will take you to the list of quotes. (I put a few good lines from Star Wars in there to get you started, but you can delete them if you want.) Add some quotes and you’re ready to display them on your site.
Find the template which controls where you want the quotes displayed. Header.php, for example, is the file you’ll need to edit if you want the quotes to display in your blog’s header, like mine do. Then just add this line of code:
if ( function_exists( 'dg_pq_getQuote' ) ) dg_pq_getQuote();
Special Note for Thesis Users
If you’re rocking Thesis, the ultimate WordPress Theme, then your job is a bit simpler. Just open /custom/custom_functions.php and add this function:
function mytagline(){ echo "<h1 id=\"tagline\">"; if ( function_exists( 'dg_pq_getQuote' ) ) dg_pq_getQuote(); echo "</h1>"; }
Then add an action to the end of the file:
add_action( 'thesis_hook_after_title', 'mytagline' );
Get the David’s Pithy Quotes plugin!
Hi, because I was missing a functionality (a widget support), I created this custom widget for your plugin, enjoy to modify it or / and include it in future releases, if you want to 😉
http://wp.podsmrkem.com/quotez-widget.zip
Peace
Thanks for awesome plugin!