The base install of WordPress is rather limited when it comes to your Title Tag, Description and Keyword Meta Tags. Expanding these tags to have custom wording is simple and can really help with unique search engine listings.
This tutorial is an extended explanation of Meta Tags in WordPress from the WordPress.org Website. View our working sample text file for a clean view of our examples.
The WordPress site tells us everything we need to know about setting custom text in you header tags. First you can hunt down a mixture of Meta Tag Plugins that can offer different custom options for your meta & title tags. However, you can setup WordPress to create custom text in your meta & title tags for you without the need of another plugin.
The Title Tag:
Add the PHP line below between your <TITLE>add here</TITLE> tags. The PHP line checks to see if the visitor is on a single page (Comments Page). If they are on the single page it will display the subject of that post in the TITLE tag.
So if it’s true: Display the name of your blog from the Tagline in your General Options and the single page post subject. The TITLE tag in this post says: TheDocBlog Custom Title and Meta Tag. Else, if they are on the main page (not on a single page / comment page) it will display the name of your blog and whatever you put in the KEYWORD1 spot.
In the KEYWORD1 spot put 1-3 different keywords/phrase. For TheDocBlog I use “Webmaster Tutorials”. When the PHP displays in my TITLE tag it will say: TheDocBlog Webmaster Tutorials At the end of the PHP line you need to replace the “REAL TITLE GOES HERE“. This is the general title that describes your Website.
Replace KEYWORD1. This is the keyword(s) to use if visitor is not on the single page post.
<?php if ( is_single() ) {bloginfo(’name’); echo ” “; single_post_title(”, true);} else {bloginfo(’name’); echo “ KEYWORD1“;}?> | REAL TITLE GOES HERE
The Description Tag:
Add the PHP line below into your meta description tag. (example below). This PHP tag works the same as the TITLE tag, I will explain the differences.
The Basic Description Meta Tag:
<META NAME=”description” CONTENT=”Your Site Description”>
This PHP tag works the same way, but has a different setup. At the end of the tag is an extra bit of PHP. <?php bloginfo(’description’);?> This PHP line pulls the description tag from WordPress admin in the General Options.
Two things need to be changed. DESCRIPTION1 A short sentence that describes your site. Then SHORT_DESCRIPTION1 which is a keyword rich short description that may go with the other two descriptions. The same as the TITLE tag, if you are on a single page it will print: DESCRIPTION1 The Post Title SHORT_DESCRIPTION1 - description (pulled from the admin area)
<META NAME=”description” CONTENT=”DESCRIPTION1 <?php if ( is_single() ) {single_post_title(”, true);} else {echo “SHORT_DESCRIPTION1“;}?> - <?php bloginfo(’description’);?>“>
The Keyword Tag:
Add the PHP line below into your meta keyword tag. (example below). This PHP tag works the same as the others.
This is the easiest tag. Replace FEW_KEYWORDS with a couple keywords, at the end of the line replace MANY_KEYWORDS with a lot of keywords.
Now in the PHP line replace: KEYWORDS1 with a few keywords. When this prints if the visitor is on a single page it will add the title of the post in the keywords, if not it will add your KEYWORDS1 keywords. Simple as that.
<META NAME=”keywords” CONTENT=”FEW_KEYWORDS,<?php if ( is_single() ) {single_post_title(”, true); echo “,”;} else {echo “KEYWORDS1,”;}?> MANY_KEYWORDS“>
Example Setup With PHP And Keywords: (view in example text file)
<TITLE><?php if ( is_single() ) {bloginfo(’name’); echo ” “; single_post_title(”, true);} else {bloginfo(’name’); echo ” Webmaster Tips”;}?> : The Webmaster Resource Center</TITLE>
<META NAME=”description” CONTENT=”Online Webmaster Guide <?php if ( is_single() ) {single_post_title(”, true);} else {echo “- Free Guides To Webmastering”;}?> - <?php bloginfo(’description’);?>”>
<META NAME=”keywords” CONTENT=”blog, webmaster, <?php if ( is_single() ) {single_post_title(”, true); echo “,”;} else {echo “tutorials,”;}?> photoshop, html, css, php”>
What The Above Example Creates For Your Main Page:
<TITLE>TheDocBlog Webmaster Tips : The Webmaster Resource Center.</TITLE>
<META NAME=”description” CONTENT=”Online Webmaster Guide - Free Guides To Webmastering - description from wordpress admin”>
<META NAME=”keywords” CONTENT=”blog, webmaster, tutorials, photoshop, html, css, php”>
What The Above Example Creates For A Single Page: (POST_TITLE = Title From Your Post)
<TITLE>TheDocBlog POST_TITLE : The Webmaster Resource Center.</TITLE>
<META NAME=”description” CONTENT=”Online Webmaster Guide - POST_TITLE - description from wordpress admin”>
<META NAME=”keywords” CONTENT=”blog, webmaster, POST_TITLE, photoshop, html, css, php”>
More About The PHP Line:
is_single() If the page is a single page, then execute the php.
bloginfo(’name’); This line displays the name from your blog based off of the Weblog Title in your WordPress admin.
single_post_title(”, true); The title of the post on the single / comment page.
Final Note:
This is only one way to setup custom header tags. Adding a meta tag plugin can assist you with custom post tags and may help speed the process up for you. However, if you take the time to learn, you will find out that WordPress can pull just about anything and put it into the header tags, just experiment.
  Good Luck,
   ~ TheDoc




Link to This Post:
Talking About: Custom Title and Meta Tags