I’ve searched long and hard trying to find a way to add the page name to the title tag dynamically to my WordPress blog page when I’m using WordPress as a CMS. I finally found the solution that I was able to understand at ‘Web Designer Wall.’ I changed his code a bit to suit my own needs and thought I’d paste the code here for anyone who may need it (and as a repository for me for future use).
The following PHP code should be placed between your title tags in the header.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | if (is_home()) { echo 'News - Pop Stalin Design: Web Design With Standards'; wp_title(''); } elseif (is_404()) { echo '404 Not Found'; echo ' - '; echo bloginfo('name'); } elseif (is_category()) { echo 'Categories - '; echo wp_title(''); echo ' - '; echo bloginfo('name'); } elseif (is_search()) { echo 'Search Results'; echo ' - '; echo bloginfo('name'); } elseif ( is_day() || is_month() || is_year() ) { echo 'Archives - '; wp_title(''); } else { echo wp_title(''); echo ' - '; echo bloginfo('name'); } ?> |
This code seems overly verbose to me but until I can figure out something more concise, this is what I’ll be using.
2 People Have Bloviated
B2 | Jan 19
There is a good plugin if don’t want to touch your templates files : “All in One SEO”
You can customize even each post and page title tags ^^
Jen | Jan 19
Thanks for the tip!