Skip navigation

Importing Quotes Into the Random Quote Generator WordPress Plugin – WP-Quotes

I’ve been using the WordPress Random Witty Text Plugin on my main site for well over a year. I’ve always had random quotes on my web pages for a variety of reasons, but mostly because I’ve been collecting quotes since I was a child and I like to share them.

Witty Text WordPress Plugin was simple and effective, and it did the job. In preparation for upgrading WordPress, I checked for updates and found that the author was now recommending someone else’s WordPress Plugin for random quotes. And, unfortunately, he’s closing his website. What a shame.

NOTE! I found a much better plugin here. Its’ called WP-Quotes. it uses SQL, it has a sexy interface and can do much more than my very rudimentary plugin. Highly recommended!

Curious, I checked out WP-Quotes WordPress Plugin and found that I really liked it. And since I now needed a replacement, it was worth the try.

The installation is quick and painless. Put the wp-quotes.php file into your /wp-content/plugins directory and the edit-quotes.php file into /wp-admin. Activate the Plugin then visit Manage > Quotes to create the database and start adding quotes.

This is great if you are starting fresh and have 5-10 quotes. I have several hundred in my random quote file. And I wanted to keep ALL OF THEM.

Importing Quotes Into the WP-Quotes Database Table

After becoming intimately acquainted with the Import feature with phpMyAdmin while importing over 1000 posts manually into WordPress over a year ago, I knew I could import my few hundred quotes into my database easily.

Witty Text worked from a text file of quotes, with each quote on a line. I had added italics and some formating in the file, so I needed to change this into a CVS text file for importing into my database.

For the import, each field needed to be wrapped in quote marks, with a comma in between, and each quote needed to be on its own line. There are three fields to import, the quote, author, and visibility. The visibility I wanted set to “yes”, which mean the quote would appear on my web page. From the Manage > Quotes panel, you can control which quotes are “visible” or shown and which are not. I wanted all of them to show and not have to go back and manually mark all 300 quotes to “show”.

To convert the text file to meet the new requirements, it was a simple matter of search and replace and the file was ready. Or so I thought.

I did my import and yikes! It borked. It wasn’t ready. I had left quote marks inside the text breaking the import.

Again, the queen of search and replace, I searched for every "," and replaced it with XXXXX. Then I searched for every ending and beginning quote mark, and replaced it with QQQQ. The only quote marks remaining would then be inside the content fields. A quick search and replace for the quote marks, changing them to apostrophes, got rid of them. I then replaced my X and Q place holders with the appropriate quote mark combination and I had a functioning text file ready for importing.

An example of the import file looks like this:

"Travel has a way of stretching the mind. The stretch comes not from travel's immediate rewards, the inevitable myriad new sights, smells and sounds, but with the experiencing firsthand how others do differently what we have believed to be the right and only way. "," RalphCrawshaw","yes"
"Nothing in life is to be feared, it is only to be understood.","Marie Curie","yes"
"Information's pretty thin stuff unless mixed with experience.","Clarence Day","yes"
"We need only travel enough to give our intellects an airing.","Henry David Thoreau","yes"

To import into a table in your database, you need to access phpMyAdmin on your server. Click on the database name, and then on the table, in this case wp_quotes. When you browse the table, you should see the three examples that were put into the database when the table was created by the WP-Quotes WordPress Plugin.

To begin, verify that you are in the wp_quotes table by checking at the top of the screen for the title to say Server: localhost – Database: databasename – Table: wp_quotes and that you are indeed in the wp_quotes table.

Import into Database Table - Checking Table Name in phpMyAdmin

Notice there are three fields in the table you need to import into. They are: quote, author, and visible. You will need this information in order to create your import. If you’ve done the search and replace and prepared the import file right, you should have three fields (sections) wrapped in quote marks, with each quote on its own line as a single record. The order should match: 1) quote; 2) author; 3) visible.

Click on IMPORT at the top of the panel.

Import into Database Table Import Tab in phpMyAdmin

Click BROWSE to select the text file ready for importing from your hard drive.

Move lower down to the box called Format of Imported File and choose CSV using LOAD DATA.

Import into Database Table Load Data in phpMyAdmin

In the fields near each option, set them as following, which means only changing the first one and last one. The rest should probably stay the same.

  • Fields terminated by – Put a COMMA (,) in the box
  • Fields enclosed by – Should be a quote mark (“)
  • Fields escaped by – Should be slash (\)
  • Lines terminated by – Should be AUTO
  • Column names – Type in quote, author, visible

Leave everything else as you found it.

Check again at the top to make sure that the title says Server: localhost – Database: cameraon_main – Table: wp_quotes and that you are indeed in the wp_quotes table, then click GO.

If there are any errors, it will be reported at the top of the screen. If there are errors, it usually means you missed a quote mark somewhere or there isn’t a quote mark at the beginning or end of the entire document. It will often tell you which line the error is on to help you track down the problem. If it only imports part of the file, fix the problem and then import the file again after either deleting the successful part of the import or choosing Replace table data with file.

Within seconds, all 300 plus quotes were imported and now ready to use.

Import into Database - Data now imported into the table in phpMyAdmin

Now, if you are old fashioned and want to do this manually, and not use the Import tab, you can use the SQL to type in your own import command. The file should be in the root directory of your site. The Import into Local Data Infile command would look like this:

LOAD DATA INFILE 'quotes.txt' INTO TABLE wp_quotes
          (quote, author, visible)
          ENCLOSED BY '"'
          LINES TERMINATED BY '\n';
          ESCAPED BY '';

Now that the quotes are imported into your database, it’s time to style them and make them look pretty.

The Layout of WP-QUOTES in Your WordPress Theme

Import into Database - Data now imported into the table in phpMyAdminThere is some confusion on how to use the WP-Quotes Plugin template file in your WordPress Theme. It’s actually very easy.

Choose where you want the quotes to be, such as the random quotes. I feature mine in the sidebar under a title called “Thoughts”. Here is the code I use in my sidebar.php, which is inside of a nested list:

if (function_exists('wp_quotes_random')) {
  echo ('<li>Thoughts<ul><li>');
  echo ('</li></ul></li>');

The WP-Quotes Plugin template tag is wrapped inside of a conditional PHP statement, which basically says, “If this Plugin exists and is active, do the following. If it isn’t, skip this whole section. Move on. There’s nothing to see here.”

You notice that there are no DIVs or CLASS for the section. The design elements are created when the web page is generated. Here is what it looks like, with a sample quote:

   <div id="wp_quotes">
      <div class="wp_quotes_quote">You know what I like best about
looking at the stars? Not the stars themselves, but all those
empty spaces between the stars. That's where I can imagine
traveling for ever and ever. That's where I can imagine infinity.</div>
    <div class="wp_quotes_author">T.A. Barron</div>

The style references are created automatically by the Plugin. There is a DIV called “wp_quotes” for the overall layout so you can wrap it in a box or control the overall look, “wp_quotes_quote” for the format of the quote itself, and “wp_quotes_author” to style the author reference. Notice that the classes use an underline (_) not a dash/hyphen (-) between the words.

In your style.css, you can control the look of the quote. An example would be:

#wp_quotes {background: transparent; margin:10px;
     padding 5px; border: solid 1px blue; }
.wp_quotes_quote {font-size:80%; color: blue;}
.wp_quotes_author {font-size:70%; font-weight:bold;
     text-align:right; color: green;}

From here, it’s up to you what you do, and how you create your random quotes.

And if you are also into quotes and collecting quotes, or just reading quotes, I’ve got a few for you.

Digg Digg | | Blinklist BlinkList | Furl Furl
Spurl Spurl | Reddit | Add to Simpy Simpy | Add to RawSugar RawSugar

Site Search Tags: , , , , , , , , , , , , ,
Copyright Lorelle VanFossen


  1. Posted March 28, 2006 at 3:55 pm | Permalink

    I already have an added WP PAGE that I keep my quotes on, with a link to it in my sidebar; is there any advantage to me using a plugin when it could possibly be a drag on the system i.e. added code, vs a seldom accessed PAGE? Seriously, just asking, convince me otherwise and I’ll install it now. TIA.

  2. Posted March 29, 2006 at 10:53 am | Permalink

    Lorelle — I really like your explanation of how to use wp-quotes and how to load data into the sql table. I have modified wp-quotes somewhat and would like to refer to your post here for additonal information on how to use the plugin. And, I would like to ask your help on resolving a CSS problem I now have because I am creating more than one wp_quotes div. I can explain further if you email me.

    Answering BillyG — there probably isn’t any need to use such a plugin if your quotes are on a page. In my case, I have 3 kinds of quotes in my sidebars. I wanted a better way to manage what I had and be able to expand the way to display the quotes.

  3. Dan
    Posted March 29, 2006 at 12:43 pm | Permalink

    Lorelle–Thanks for the detailed explanation. I’ve been adding quotes one at a time with this plugin, but eventually I’ll want to do an import–and you’ve saved me a bunch of time and headaches!

    Regarding a page for quotes, this plugin also provides code that will pull out the entire set of quotes into a page–just create a page and add

    CSS can be used to style the text here as well. I like this plugin because it allows me to provide random quotes on individual pages AND present an entire page.

  4. Posted March 31, 2006 at 2:19 pm | Permalink

    Thx guys, I guess I didn’t wait long enough to be convinced.

    I suppose I understand your wanting to pull them out individually for a post etc. but I’ll just view/search my page since I’m really just putting them there for people to view if they choose, nothing special. The funny thing is (or maybe sad lol), two of the most popular hits on my blog are for the Quotes Page and a random post thanking somebody for mentioning that WinAmp had a new update available (since I never have recv’d emails from them). As soon as and spidered me, those hits took off so I guess it was worth the 5 minutes for me lol.

    Thanks for replying though and G/L.

  5. Posted November 25, 2006 at 12:28 am | Permalink

    Mmmm, 2nd comment, Lorelle – SO MUCH THANKS…I already commented to the other websites (Dustin’s) hosting the wp-quotes plugin (appears he initiated with a partner another quote plugin titled “utterquotes” by d.barnes, & rick dooling. Okay, but I have exec-php installed and even though am a real novice w/ php coding, I did not want to give it up, since it is a NEW version with a malformed ‘ping’ (correct description of an admin interface function?). BUT even if I cannot get that function to work any more than you offer (your T.A. Barren quote with .php coding included, it was worth it to see writing on the post page (the exec-php is for direct php coding on a post). I did not want a whole page of random quotes, will try your method using the suggested code of Thoughts’);
    echo (”);

    Unfortunately, I actually did not get the above (with random use) to work, I had to copy/paste the 2nd full text version to my post…and, also, in the future would like to know what the “topic” insert is referring to when the wp-quote states it has the ability to parse wp_quotes($topic) …maybe they are refering to categories? Anyway, I will try mixing your 1st & 2nd examples to come up with a working “in-post” code compatible with the exec-php 3.0 plugin (using division tags, and identifying specific posts with $1, $2, etc…even if it is one at a time ul/ li/li listings. Thanks, I have just left soooo many frustrated (excerpt plugin, ajax calendar plugin, etc…comments in inquiry – without response, due to NO success, that I thought I would overcompensate here. THX Claire

  6. Posted November 25, 2006 at 8:59 am | Permalink

    I do not recommend using this technique inside of a post. That’s an invitation to trouble. Even if you are using PHPExec or RunPHP. It is designed to be used on a template file not a post.

    If you want to use it on a Page, then you can create a Page template file with the code on that and then enter in whatever other custom text you want from the Write Page panel. But this is designed for use in template files, not posts.

  7. Posted June 14, 2007 at 7:39 am | Permalink

    I need some help…

    How do I do this part?

    ‘Put the wp-quotes.php file into your /wp-content/plugins directory and the edit-quotes.php file into /wp-admin.’

  8. Posted June 14, 2007 at 12:05 pm | Permalink

    I am still using an old version of the Plugin, so these steps may be obsolete with the new version. Check with the author for the current installation instructions.

    Just as you would upload any WordPress Plugin, via an FTP program or otherwise, that is how you put the file on your full version WordPress blog. For more information on installing WordPress Plugins in general, see How to Install, Configure, and Use WordPress Plugins.

  9. Posted June 21, 2007 at 1:01 pm | Permalink

    Thanks for the info. I will try to work with that and see how far I get.

  10. Posted May 27, 2008 at 3:26 am | Permalink

    Is it just me or has the WP-quotes plugin stopped taking new quotes since 2.5 came along? Anyone else gettign this problem?

  11. Posted June 1, 2008 at 7:19 pm | Permalink

    @ jamesspratt:

    Have you checked for an updated version? The database tables were dramatically changed in the new version and I haven’t yet found a fix. Let me know if you do. Thanks!

  12. pcheing
    Posted July 1, 2008 at 9:06 pm | Permalink

    I googled for this exact plugin and was able to install it like you said, “quick and painless”. Instructions were very helpful, but once I got the plugin installed, I stopped reading the rest of the post, since this was all I was looking for. Maybe I’ll read the rest of the post at another time. Great blog by the way!

  13. Posted July 6, 2008 at 1:42 pm | Permalink

    same problem as jamesspratt. Since i updated to WP 2.5., i cannot update my wp-quotes database by the admin panel. *Sigh*

    too bad. Please tell if someone has a solution…!


  14. Posted July 6, 2008 at 6:32 pm | Permalink

    @ LOmiG:

    Have you contacted the Plugin Author? That is the place to start.

  15. Posted July 7, 2008 at 12:36 am | Permalink

    i have the answer…found on the comments left on the plugin’s blog :

    You have to copy the file edit-quotes.php in the wp-admin/ folder.

    that’s it. And, on my blog, i have to edit a quote and save it, before being able to add new ones. But it works this way.

  16. Posted December 27, 2008 at 7:04 pm | Permalink

    Thanks for the info. I have been working on a similar random quote plugin called ‘Fortunate’ – which you might choose to use if you don’t wish to maintain the quote database yourself. Fortunate uses a quotation server with (currently) over 27,000 quotations from 71 different databases.

    • Posted December 28, 2008 at 10:57 am | Permalink

      That sounds cool, for those who don’t want to restrict their quotes to specific subjects and just want anything and everything. Do you have a way of restricting by keyword, subject, or category all those quotes in your Plugin for those who do want control over them?

  17. Posted December 10, 2018 at 5:13 am | Permalink

    Thanks it’s helpful for me

6 Trackbacks/Pingbacks

  1. […] I’ve been using other WordPress Plugins to make my random quotes work, so I wanted to use the same quotes but with this new Plugin. To get my huge list of quotes into the WP-Quotes table in the database, I came up with a method for importing my quotes into the database. […]

  2. […] I recently noticed Llorelle was endorsing and explaining a new quotes plug-in, which can be found here. […]

  3. […] The problem I faced switching Plugins was that all my wonderful quotes were in a CSV text file and now they had to get into the WordPress database. I describe the solution to importing my quotes into the database in Importing Quotes Into the Random Quote Generator WordPress Plugin – WP-Quotes. […]

  4. […] understand some of what I’m talking about below, check the instructions at Lorelle’s Blog. Using the instructions at Lorelle’s blog  I changed the formatting from the one required by […]

  5. […] managing your quotes from the WordPress Administration Panel. I've also written an article on Importing Quotes Into the WP-Quotes WordPress Plugin Random Quote Generator from a text […]

  6. […] Importing Quotes Into the Random Quote Generator WordPress Plugin – WP-Quotes […]

Post a Comment

Required fields are marked *

%d bloggers like this: