I want the title of my blog to appear as one thing while its on the homepage, and something else when it is everywhere else on my blog.
Does this code look right?
<title>
<?php
if ( is_home() )
echo "Blog Title" //When on the homepage
else
echo ucwords(wp_title('',true)); //Name of blog article
echo ucwords(get_bloginfo('name')); //Followed by site name
?>
</title>
Any feedback is appreciated.
Only one thing you should pass
false
in thewp_title
functionecho ucwords(wp_title('',false));
wp_title function echo the title if the second argument is passed as true, if it is passed false it will return the title for further operations
Assuming that your functions are working and retrieving the correct data, that code is perfectly acceptable for what you’re using it for.