Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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:

strip_tags(get_bloginfo('name'));

I'd go with the 3rd option, since it's the fastest method without changing to much.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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