Pieces of WordPress theme code: a repository

The great thing about open source is that you can build on what others have done. In my quest to port an open source web design into a WordPress theme, I’ve used bits and pieces of WordPress theme code that have served me well in previous designs.

I am posting these pieces of code here so that this post will serve as the repository in case I need to customize another theme. Please feel free to suggest additional code bits so that I can add it here. Just post it in the comment field and enclose it in code tags.

SEO friendly title

I got this from K2, what this does is place the title of your post before your blog name. The conditional tags take out the at, which connects the post title to your blog name when you�re, for example, in the home page. You don�t want your home page title to start with at.

<?php wp_title(''); ?> <?php if ( !(is_404()) && (is_single()) or (is_page()) or (is_archive()) ) { ?> at <?php } ?> <?php bloginfo('name'); ?>

Here’s another implementation as posted in the Dech blog.

< ?php wp_title(' '); ?>< ?php if(wp_title(' ', false)) { echo ' · '; } ?><?php bloginfo('name'); ?>

Make header image clickable

This is a tip I got from K2 to make the header image clickable. Replace the starting div tag for the header with this:

Support this blog and independent reporting on Cebu

6 responses

  1. I’ve try showing google adsense 2 blocks on 1 page, but just one showed. Confused

  2. Great Post. Very Helpfull information. Thanls, guys. Jürgen from Germany 🙂

  3. ~

    Hey there.,

    Have any idea how many WordPress sites that I searched to try to figure out how to add a simple URL Click to my WP banner image?!?! Even the guy who DESIGNED the theme did not have this info on his page.,

    I only just installed WP this evening and am hacking it as I type this., all I can say is Boy do I miss being able to edit in Dreamweaver., what the heck are people thinking with this WP stuff., what a learning curve.

    Now it seems that I have to learn PHP, CSS and MySQL, all of which I have avoided for many years., oh well., time to burn my eyes out on the screen even more now.,

    THANKS for making this one piece of my job a little easier., will be checking out more of your site soon.,



  4. AK,
    You can edit themes with Dreamweaver. I wrote about it in this blog: http://max.limpag.com/2006/06/07/how-to-edit-wordpress-design-using-dreamweaver/

  5. ~

    Hi Max;

    Yeeesh., yes., thanks., I saw that post., but I wonder., which is more time consuming and hair pulling., doing as you suggest and diss-assembling and then re-assembling the various code bits., or just going to the various files and editing there?!?!

    This all seems so archaic in the year 2007., who the heck would “design” a system (hah., some system) where the design code for one site is in ten different files and NOT viewable or editable in ONE system or piece of SW at one time?!?

    One can only hope that we will look back on this time of “design” and say,. goodness., glad that we are way past that mess! It just seems a bit overly convoluted to me., yes?



  6. AK,
    If you want just a single file to control your design, you can choose not to break it up. Include the code for headers, sidebars and footers in index.php. The breaking up of the files allows you to re-use code (i.e. header, sidebar, footer) for different sections of your WP blog: index, post entry, page, archive etc.

Leave a Reply

Your email address will not be published. Required fields are marked *