A few Wordpress Tricks.
Posted on Friday the 9th of March, 2007 at 1:56 pm in WordPressJust 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('»',false), '» ');?>
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:
<?phpif(is_page()){include('single.php');exit;}?>
I wanted to be able to use javascript in some of my pages so I added the following to my header.php:
<?phpif(is_page()){$j = get_post_meta($post->ID, 'header', true);if($j != ''){echo $j;}}?>- Use the following to copy and paste the code.
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['REQUEST_URI'],'google234234234234.html') == false){header("HTTP/1.1 404 Not Found");}else{header("HTTP/1.1 200 OK");}?>


Just to let you know the first tip shows the charecter raquo not the word.
Reply to JamesThank you, it has been fixed.
Reply to AaronWhat would happen if you added the Javascript header trick to a post?
Reply to Johnwow, a great tips-n-trick….may i re-write and translate this post into my bahasa indonesia language in my blog ?
Reply to uwiuwYou may, as long as you give credit to the original source and include a link to this page.
Reply to Aaronabsolutly, i will put credit on you :-D. thank you very much
Reply to uwiuw