0

I'm creating a function to handle the titles of the pages, posts, home page etc.. however I have run into a problem.

Here is the code in the Functions.php :

function theTitle() {

   $siteName = bloginfo('name');
   $sitePage = get_the_title();

   if (is_home()) {
        echo $siteName;
   }
   if (is_page()) {
        echo "(". $sitePage . ") » " . $siteName;
   }
}

When you are on the homepage, the title is:

<title>This is the title specified in settings</title>

However, when you go to an individual page the title is:

<title>This is the title specified in settings(About Us) &raquo; </title>

As you can see, it is outputting the $siteName first, instead of adding it to the end. Has anyone come across this before? Do you know why?

Thanks

1 Answer 1

1

bloginfo() echoes the return value of get_bloginfo(), so use get_bloginfo().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.