blog

WordPress: One Way To Display The Perfect Title

While the work has been sometimes laborious to get this blog finished and ready to view, one of the more difficult things was to get the details right in the <TITLE> tag. Many of the snippets of code out there suggest using various separators and little tricks to determine if the user is at the home page. What I was after was this:

If at the home page, display the blog’s name and description only. If on an article, display only the title of that article. The resulting code is a mix of php snippets found all over the web but one great way to make the links a search engine provides look better.

You’ll need to copy and paste this into your active theme’s header.php file. Click on the image below to get plain text of the code:
What the above snippet uses on line #1 is the is_home() php function to check for the home page and, with an if… else statement, perform some work. On Blogging Calwell, you’ll find this implemented on all pages.