I would like to style parts of bloginfo name from a filter. The only thing I want to do is change the site-title of the blog to include HTML so that I can do individual font-settings on part of the name.
I’m using the twentyeleven and wonder how I can do this in a filter.
When I add a filter for bloginfo and modify the name, it gets modified also in the title of the page and in the title attribute of the A element. I would only like to modify the bloginfo[‘name’] that is shown inside the A element.
Is there someway possible to check the context you are in while the filter callback is called for more fine grained control of the output?
You can’t check the context while the filter callback is called, because the element is already in the frontend. There are 3 solutions though:
1. jQuery
Search for the element and add html to the places in the name.
2. PHP in element
Get the bloginfo(‘name’); in the element and change it on that place using PHP.
3. PHP in header
Add HTML to your bloginfo(‘name’) and strip it back out in de header.php file where the title is generated using the strip_tags() function:
I’d go with the 3rd option, since it’s the fastest method without changing to much.