WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to filter the blog's name for Google's user agents.

I have tried the_title, the_content, comment_text, single_post_title, wp_title, category_description, bloginfo hooks, but none of them worked!

Can anybody help me?

share|improve this question

You said that you have tried using the bloginfo filter, but this code works fine:

function wpse_78345_alter_blog_name( $output, $show ) {
    if ( $show != 'name' ) return $output;
    return 'New blog title';

add_filter( 'bloginfo', 'wpse_78345_alter_blog_name', 10, 2 );

This filter will only fire on the front-end, not the dashboard.

share|improve this answer

The value is from get_option('blogname'), so you can filter pre_option_blogname:

add_filter( 'pre_option_blogname', 'wpse_78345_blogname' );

function wpse_78345_blogname()
    return 'Haha!';

Do not filter option_blogname. This is wrong: you are wasting time with that, because WordPress will parse the option cache for the stored result, and then you don’t even use it.

share|improve this answer
as I know pre if for detabase writes. I just want to edit blogname for google user agents! – ahmadali shafiee Jan 5 '13 at 17:14
I forgot to say that I want to filter it for google's user agents! – ahmadali shafiee Jan 5 '13 at 17:16
@ahmadalishafiee Then go and edit your question with this info, please (also the title). – kaiser Jan 5 '13 at 17:18
I don't think the title need to be changed. But I edited the question – ahmadali shafiee Jan 5 '13 at 17:20
@ahmadalishafiee No, pre_option_ happens very early in get_option. How to handle cloaking based on User-Agent headers is off topic here. – toscho Jan 5 '13 at 17:21

There were an answer 5 mins ago! and that worked! I used add_filter('option_blogname','HalfSpace_filter',1,1); and that worked!

share|improve this answer

Your Answer


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.