Allows the user to create a list of quotes, and then pull either a random or specific quote from that list using custom template tags.
Current version: 1.0
0.1 – made within the functions.php file of the theme
1.0 – created plugin, cleaned things up
Copyright 2008 Corey Dutson (email : firstname.lastname@example.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Under the settings section, navigate to the RandomQuotr section
- Add quotes to the textarea on the left-hand side. Quotes are split by carriage returns (line breaks)
Once that’s done, you can use the following hooks to display the content:
Getting a random quote
random_quote(); – this will display the text automatically.
$quote = get_random_quote(); – this stores the text within a variable.
Getting a specific quote
target_quote(3); – this will display the third quote in the list.
$quote = get_target_quote(); – this stores the text within a variable.
- I’m using target_quote(0) and nothing’s coming up! I know I have a quote in there though
The list starts at 1, not 0.
- target_quote and get_target_quote are not doing anything!
Make sure that you are passing in a valid value. If you are passing in an invalid number (below 1, above the number of quotes), a non-number (“forty”), or there are no quotes to get, all of the functions will return null.