I am new to WordPress, and have been asked to change a value in the title tag.
The title tag is of the format: “site name | slogan” which is set dynamically in the header.php (seems standard code for WordPress from what I can see from other posts).
It is the slogan on the home page only that I need to change.
All other pages within the site are ok, I just need to change the home page, and I have no idea if this “slogan” portion of the title is coded somewhere, or set as an attribute etc.
Where and how do I change it?? Thanks
You can do one of two things. The first, recommended way would be to use a plugin like WordPress SEO. Install it, and replace the <title>
tag in your header.php
file with:
<title><?php wp_title(''); ?></title>
Or you can change the title only for the home page by using the is_front_page
or is_home
conditionals.
<title>
<?php
bloginfo('name'); // this is the blog name
echo ' | '; // seperator
if(is_front_page())
{
// what you want for the home page here
}
else
{
bloginfo('description'); // this is the slogan
}
</title>
That’s a bit sloppy though, and I’d recommend looking into using wp_title
instead.
Twenty Eleven’s header.php
has a good example of this:
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );
?></title>