// you're reading...

Tutorials

Wordpress Random Tagline Tutorial

Tutorial Revision: I’ve changed my theme since this tutorial was written, but it is completely applicable to any wordpress theme that displays a tagline.

In the spirit of the open source community, which has benefited me so much over the last 10 years, I humbly offer up a tutorial that will allow you to randomize your tagline within Wordpress. I use the Hemingway theme, and you’ll notice that the tagline in the header of my site displays a different saying on each page refresh as illustrated in the screenshot below.

My tagline

This is a pretty easy modification, so let’s get started. I’ve included all needed files here as well.

  1. The first thing you should do is download the zip file which contains the actual files you’ll need to generate the random tagline
  2. Unzip the archive and make sure you maintain the directory structure
  3. Now the fun stuff begins. Open quotes.dat in a text editor, preferably one that shows line numbers, and replace my own mayhem with your own. Be sure to avoid empty lines, as they will “display” anyway, and you won’t see any taglines when that happens.
  4. Upload quotes.dat to the root directory of your blog. I’ve assumed that you have put Wordpress in a folder called “blog.”
  5. Upload quotesmain.php to your hemingway theme folder. You do not need to make any changes to this file.
  6. Now, go to you Wordpress Admin, select Presentation > Theme Editor > Header. Once again, I’m using the Hemingway theme, so I’ll assume you are as well. This tutorial, however, will work for any theme you choose that supports a tagline.
  7. At approximately line 56, replace < ?php bloginfo('description'); ?> with < ?php include('quotesmain.php'); ?>


That’s it! Refresh your page and you should start seeing the random taglines show up. You can, of course, style your tagline anyway you’d like. To do that, simply go to Presentation > Theme Editor > Stylesheet and modify the #header p rules anyway you like. For example, I use #header p{
padding-top:48px;
margin:0;
line-height:1em;
color:#ffffff;
font-size: 155%;
font-family: Georgia, "Times New Roman", Times, serif;}
on my site, and that’ll get you started!

I hope this helps, and if you have any questions, please let me know by replying to this thread!

Enjoy!

Tell everyone you know: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Technorati
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • MisterWong
  • De.lirio.us
  • Ma.gnolia
  • StumbleUpon
  • YahooMyWeb
  • Furl
  • MyShare
  • Netscape
  • NewsVine
  • Slashdot

Discussion

3 comments for “Wordpress Random Tagline Tutorial”

  1. Nice script it seems. Though I got some problems.

    How can it be that I get the following line as text instead of a socalled function with the quotes?

    Would be glad if you could help me out on this one ;-)

    Posted by edvin | November 5, 2006, 7:40 pm
  2. Hi Edvin,

    The answer is that you need to remove the space between the opening < and the question mark at the opening of the function: < ?php

    Basically, that extra space in there is causing the PHP to render as text. Just remove the space between the first < and the ? and you'll be all set!
    For some reason, I am having issues putting functions within the code tag, so I'm not able to properly illustrate, but I've attached a text file with the proper code which you can copy/paste into your header file.

    Posted by Gino Guarnere | November 6, 2006, 9:09 pm
  3. Thanks, Edvin, for this tutorial. It’s great!

    But I’m running across a problem. I’ve done exactly what you’ve described above, yet the line showing up -instead of the random tagline that should be there- is listing my blog name instead.

    I’m using Hemingway 0.19
    Wordpress 2.1.2

    The only difference is that my Wordpress content is not in a folder called blog, but directly in the root. Could this be the problem?

    Thanks in advance for your help!

    Posted by marygrace | March 6, 2007, 5:08 pm

Post a comment