From working with an in house SEO team, I regularly get asked about changing particular sections of text within WordPress sites, the answer usually lies within an excerpt, a widget or a custom field. In the past, one of the more troublesome snippets has been the on page title - this is usually a h1 or h2 tag near the top of the page, just above the content.
Having the right page title is key to both users and search engines. SEO's for example will usually want to change this title to gain every ounce of value from the pages content. Other users may want the title to say something like "Learn more about our products" as opposed to simply "Products".
The fact that this title is generally called dynamically by WordPress means changing it can have adverse affects elsewhere if it's not done carefully.
What could go wrong?
For an SEO, a web developer or a hardened WordPress veteran there is usually a straight forward workaround to these problems......but there shouldn't have to be.
A solution can by applied with a tiny php function and a simple custom field.
Add the following to your functions.php file
function customTitle(){ global $post; $customTitle = get_post_meta($post->ID, ‘custom_on_page_title’, true); if(!$customTitle){ the_title(); }else{ echo $customTitle; } }
This function will search the page for a custom field called custom_on_page_title which contains your custom title, if it doesn't find one, it will simply display the default WordPress title.
On whichever page needs a custom title, create a custom field with the name custom_on_page_title and set the value to whatever your title should be.
The next step is to add it to your template file
And you're done!
I like this useful little technique because it adds a bit more flexibility without compromising any of WordPress's native functionality.
This is realy interesting....Im new to s.e.o but I do keep a travel blog. 1 question, How do I access the functions.php file? Is it through dashboard?