Great WordPress Titles
Whether for SEO purposes or just for the sake of having good page titles in WordPress, here’s a great but of code to help out:
1: <title>
2: <?php
3: if(is_single()) {
4: wp_title('', true);
5: echo ' » ';
6: bloginfo('name');
7: } elseif(is_category()) {
8: wp_title('');
9: echo ' » ';
10: bloginfo('title');
11: } elseif (is_search()) {
12: echo $s;
13: echo ' » ';
14: bloginfo('name');
15: } else{
16: bloginfo('title');
17: wp_title();
18: }
19: ?>
20: </title>
If you look at the different sections of this blog, you will see this in action. Here’s what you should see:
Single Post Page
The post title will be first, followed by the blog title.
Category Page
The Category title will be first, followed by the blog title.
Search Results Page
The search term is used first, followed by the blog title.
Home Page
The Blog Title is the only title used. You can add the blog description if you like, though I’ve chosen not to.
Having the post title first puts the keywords first, and the blog’s title, which will be used a LOT throughout your blog, at the end. This might help keep each page title more unique in Google’s eyes.
Any ideas, tips, suggestions, or questions, please let me know…
