Customizing Title Tags in Wordpress Without Using a Plug-in - Recommended Wordpress Title Tag Script
(Page 4 of 4 )
After learning the basics of the default Wordpress title tag scripts, we can formulate ways in which we can customize the title tags. The specifications are the following:
Clarity of titles (title should be direct and relevant to page content whether it is a post, pages or categories).
You can decide the title of your front page (the home page title tag can be customized without using the blog title at all).
In your Wordpress pages (not the post), the title of the page when viewed in the browser should be exactly the same title you placed in the “page title” in the “creating a new page” section in the Wordpress admin panel. This will make the title tag exactly what you need it to be.
Wordpress category titles should reflect the exact category and nothing else.
The recommended title tag script is shown below. Copy and paste this to your header.php and replace the old title tag, remembering to back up first.
<title><?php if (is_single() || is_page() || is_archive()) { wp_title('',true); } else bloginfo('name'); ?> </title>
The concept behind this script is simple. Since in Wordpress, the post, the pages and the category name can be edited/customized, we can use this feature to formulate optimal title tags.
In the code is a series of conditional statements that follows this set of instructions: If this is either a post or pages or an archive (such as categories), then display the assigned name of the variable. If not, just display the blog title.
In this way, you can have the title of your post or pages exactly the way you intended it to be. The result is a user-friendly title which will make it easy for visitors to find relevant information on your site.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |