A quick wordpress tip
Quite busy at the moment so I’ll get round to a proper post soon. However I’ve got a neat little wordpress tip that might help you out.
I’m currently working on quite a cool site for a female singer. It’s going to be powered on Wordpress and it’s nearly ready to release so you’ll see it on my portfolio very soon. Part of the design was to use image replacement for various headers (I didn’t want the performance hog of siFR) and to do this you need a unique way to reference a header.
With Wordpress you only have one page.php so I can’t have separate div elements for each page (unless I did some over the top logic) so the best way to replace the headers was to give each h2 element a class. Ideally I’d like the page title to be the class name, like this:
<h2 class="<?php the_title(); ?>"><?php the_title(); ?></h2>
That will return the page title and insert it into the h2 element and into the class attribute, but the snag being a page title often begins with a capital. To work round this we can use PHP to return the value lowercase:
<h2 class="<?php $class_title = strtolower(get_the_title()); echo $class_title; ?>"><?php the_title(); ?></h2>
It works perfectly.
Snags
This method only really works with a single page title (music, photos, about) so you might need alternative methods for lengthy page names. But for this project it works a treat
Posted on Monday, May 25th 2009 and there are 2 comments
Categories: Tricks n Tips


2 Comments
Part of the design was to use image replacement for various headers (I didn’t want the performance hog of siFR) and to do this you need a unique way to reference a header. 70-350
70-648
70-551
Posted by John on Saturday, August 1st 2009
Nice, hope it will work.
Posted by help me essay on Wednesday, March 3rd 2010
Page 1 of 1
Contribute
Fields marked with * are required. Your email will not be shown.