free hit counters
If you are using Internet Explorer as your browser please be running at least IE 7 or above. This site does not support IE 6 or below. Go here for the latest free version including easy download and installation instructions If you want to make it real easy on yourself, download Firefox , the most popular browser in the world. It's free and simple. You'll be so glad you did.
Jan
15
2009

Rotating random text on every post or page

If you look at the header in this site you’ll notice that every time you go to a new post or page, the quotes in the header at the top left keep changing.  You can do this with any type of text.  To put it in the header you can follow this tutorial…

First, download the Random Quote plugin here and follow the directions from their website to install it

If you have the Thesis OpenHook plugin installed go the “header” box and drop this code in…

<?php
wp_quotes_random();
?>

Make sure to check the box to run PHP

You can drop that code in any box in the Thesis OpenHook plugin

Next go to WP Admin area—>Posts—> Qutoes and follow the directions to add your own custom text

If you not using the OpenHook plugin, in your custom_functions.php file add this code. You can put it anywhere you want but I recommend putting it at the top after the <?php tag. Always describe the function and put it between the comment tags /*  */ at the beginning shown below in green. The comments aren’t shown on your rendered page and it just makes things easier for you to remember…

/*random text on every post or page*/
function name-your-function () {
wp_quotes_random();
}
add_action: (’thesis_hook_header’, ‘name-your-function’);

You can add this any place else, use the hook map to see your options

An important note about the header in Thesis Hacker.  It contains clickable image maps and to give you a theory of how I built it go here.  This is important for this particular way of placing this plugin.  You can place this plugin anywhere you want on your site but to put it in a header that has clickable image maps this is a great way of doing it…

Here’s the code I put in my custom_functions.php file

function my_function() { ?>
<div id =”imagemap_header” ><img src=”<?php bloginfo(’template_directory’) ?>/custom/images/thesisheader2.png”  alt=”clickable header” />
<ul>
<li class=”title”>
<a href=”http://www.thesishacker.com/” title=”take me back to the home page”></a>
</li>
<li class=”rssfeed”>
<a href=”http://www.thesishacker.com/?feed=rss2″ title=”Join and learn”></a>
</li>
<li id=”wp_quotes“></li>
</ul>
</div>
<?php }
remove_action ( ‘thesis_hook_header’,'thesis_default_header’);
add_action (’thesis_hook_header’, ‘my_function’);

All i did was add another list item or li to my old header function, and gave it an id of wp_quotes

Here’s what I put in my custom.css file…

.custom #imagemap_header {
width: 950px;
height: 190px;
position: relative;
}
.custom #imagemap_header ul {
margin: 0;
padding: 0px;
list-style: none;
}
.custom #imagemap_header .title a {
position: absolute;
width: 493px;
height: 140px;
top: 47px;
left: 235px;
}
.custom #imagemap_header .rssfeed a {
position: absolute;
width: 120px;
height: 33px;
top: 136px;
right: 50px;
}
.custom #wp_quotes {
position: absolute;
width: 10em;
z-index: 1;
font-size: 155%;
font-style: italic;
}

Again, all I did here was to add the last chunk of code to my existing styles for my header.  I gave #wp_quotes a position of absolute so that I could move it around freely within the #imagemap_header. I gave it a z-index of 1 so that it would lay on top of everything else and not be cut off  if I moved it close to the thesis hacker image field or the subscribe image field.

For more on the z-index go here

For more on absolute positioning go here

Leaving a comment with code in it...

If you would like to leave a comment and you have examples of code you want to show, you must "escape the code". This allows the entire code to show correctly by inserting certain variable around certain tags to make them show. If you don't "escape the code" your code will show up broken, mangled, and it won't be able to be seen correctly. "Escaping the code" is very simple...

  1. Copy your code you want to show
  2. Click here to go to the site to escape the code
  3. Follow the directions, it's so easy
  4. Once you have the escaped code copied, paste it in the comments area where you want
  5. Now you can enjoy life


Go ahead, leave a comment...

{ 8 comments… read them below or add one }

Jeremy Reeves May 1, 2009 at 8:46 am

Hey,

This tutorial actually didn’t work for me. I installed the plugin and got it working properly, and copy/pasted the code you said into Openhook…but no quotes are showing up on the side.

Is there any way you could look at my code to see if I’m doing something wrong?

Thanks, I LOVE the site!

Jeremy Reeves
http://www.ControlBeatingCopy.com

P.S. I also tried using a note and alert – they don’t work either. I thought they’d be really simple but for some reason they’re not working. I also tried doing the tutorial to switch the header/nav bar and that didn’t work either. Pretty much nothing I’ve tried to do “custom” is working…and I can’t figure out why!

Reply

Nasty May 1, 2009 at 6:42 pm

Well honestly I’ve had some problems with the open hook plugin myself and I don’t use it much. Everything I do i put in the custom_functions.php file and the custom.css file. As for the tutorials not working, they work for everyone who has tried them so I’m wondering if you have a problem on your back end with your server.

Make sure every time you make changes to your custom files, you are saving it, uploading to the server in the appropriate place, and reloading your page after

The header/nav bar switch tutorial has worked thousands of times. I think you just have a typo somewhere.

The note and alert works, it’s part of the thesis design. Makes me think you’re just missing something simple like a quote, bracket, etc. This is the one problem of coding. It could be just a simple little typo that’s stopping your code from rendering properly.

Unfortunately, I have no way of seeing your functions code

Reply

Jeremy Reeves May 4, 2009 at 3:13 pm

Ahh gotcha.

I got my alert/note to work and the quotes ended up working…still can’t figure out the nav bar though! lol

Oh well..I’ll figure it out eventually

Thanks for the help!

Jeremy Reeves
http://www.ControlBeatingCopy.com

Reply

Nasty May 4, 2009 at 3:45 pm

What’s the issue with your nav bar? Maybe I can help

Reply

Robert May 17, 2009 at 8:07 pm

Hi thanks for your great tutorials.
I pasted this code into Before Sidebar 1 in openhook

and this code into custom.css
.custom #wp_quotes {
position: absolute;
width: 10em;
z-index: 1;
font-size: 155%;
font-style: italic;
}

but now if i add calendar or any widget to that sidebar1 the quotes block hide them.
So for example the calendar i can see only half of it.

Your help is appreciated.
Thanks

Reply

Nasty May 18, 2009 at 1:32 pm

you have a link to your site?

Reply

Robert May 18, 2009 at 7:27 pm

I am afraid not, still testing on local, it is a fresh install of wordpress + thesis 1.5, 3 columns, the content column is in the middle, just like your site.

Thank you

Reply

Robert May 18, 2009 at 7:50 pm

Hi again, I have just figured it out
it is because of
position: absolute;

I deleted this line from costum.css

Thanks and keep on :)

Reply

Leave a Comment

Previous post: Make an image show up on only one page

Next post: Remove an avatar from selected pages