Trying to make tiny PHP script for displaying Blog Name
-
I have multiple WP blogs running on my site with 1 set of template files for all of them. In my template file it displays the blog name like this: Blogs ~ Personal Blog. Using the following code…
<div>Blogs ~ <?php bloginfo('name'); ?></div>
However on my site I do not refer to one of my WP installations as a blog. I want the template to only display the bloginfo(‘name’) and take off the “Blogs ~ ” for the WP one I do not refer to as a blog.
I was thinking that I could have a PHP script echo just bloginfo(‘name’); if it is a non-blog WP (Site News) and echo “Blogs ~ bloginfo(‘name’);” if it is considered a blog. I attempted to make a small script to do that with an if statement that compared the bloginfo(‘name’) to the actual name of the only WP install at this time that is not considered a blog “Site News”…
<?php if (bloginfo('name') == 'Site News')
{ echo (bloginfo('name')); }
else { echo ("Blogs ~ " . bloginfo('name')); }; ?>
Here is what this code outputs to the browser…
“Site NewsSite NewsBlogs ~ “
It should output “Site News” if it is the site news blog and output “Blogs ~ Blog Name” if it is another blog.
It seems as though either my php code is bad or the WP bloginfo() function is messing it up. Can you see the problem or do you know of another solution? Thanks!
- The topic ‘Trying to make tiny PHP script for displaying Blog Name’ is closed to new replies.