WordPress Titles With No Plugin
Like other WordPress users, Web designer Chris Ferdinandi is one of many who would prefer to use little to no plugins at all when it comes to certain website functions. In his case, he decided to drop the All-in-One SEO Pack plugin in favor of a fewer lines of code in his site’s header.
In his customized header, he came up with a better title content using the following snippet below to replace the default in the header.php file:
<title>
<?php if (is_home ()) : // if homepage ?>
<?php bloginfo('name'); // display the blog name ?>
<?php elseif (is_category()) : // if category page ?>
<?php single_cat_title(); // display the category title ?> | <?php bloginfo('name'); // display the blog name ?>
<?php elseif (is_single()) : // if an individual post ?>
>?php single_post_title(); // display the post title ?> | <?php bloginfo('name'); // display the blog name ?>
<?php elseif (is_404()) : // if 404 page ?>
Page not found.
<?php elseif (is_page()) : // if a page ?>
<?php single_post_title(); // display the page title ?> | <?php bloginfo('name'); // display the blog name ?>
<?php else : // everything else ?>
<?php wp_title(‘’,true); // display the default WordPress title ?> | <?php bloginfo('name'); // display the blog name ?>
<?php endif; ?>
</title>
As for the description meta tag, since they’re often used by search engines to display just a few lines about the site in their results, he decided to add this below the title tag:
<?php if (is_home ()) : // if homepage ?> <meta name="description" content="<?php bloginfo( 'description' ); // Pulls site description ?>"> <?php endif; ?>
Ferdinandi says that the if
(is_home())
statement is to tell WordPress to show only this content on the landing page.