A few WordPress Tricks.

April 9, 2007 by aaron

Just a few little tips for WordPress:

If you don’t want the titles of posts to have the » character before them for SEO purposes just use:

< ?php echo trim(wp_title('&raquo;',false), '&raquo; ');?>

I was sick of my index.php being used to display pages, so I added the following to the top of my index.php to force WordPress to use single.php for all pages:

< ?php

I wanted to be able to use javascript in some of my pages so I added the following to my header.php:

$j = get_post_meta($post->ID, &#039;header&#039;, true);
    if($j != &#039;&#039;){
        echo $j;


Now anytime I need special style or javascript code added for a particular page I just add a custom field with the name header.

Have you ever tried to validate your WordPress site to use with Google Webmaster Tools? It can be a pain depending on the way your permalinks are, and even if those don’t cause a problem when Google tries to go to a random URL if the header isn’t 404 then it fails. Normally I just picked an off-time and renamed the htaccess file to the same as the validation file, validated and then changed it back. Well not anymore. Just add the following to your theme’s 404.php page and you should be all set. This will allow it to work even if Google doesn’t check it for an hour or ten.

Obviously you are going to change the whole google23423423423423.html part to the filename Google gives you.

<?php if(strpos($_SERVER[&#039;REQUEST_URI&#039;],&#039;google234234234234.html&#039;) == false){
        header("HTTP/1.1 404 Not Found");
        header("HTTP/1.1 200 OK");
Categorized as:
comments powered by Disqus