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 am developing a plugin for WordPress 3.5. My blog's default title is "Test". Here is some code of my plugin:

add_filter('wp_title', 'my_replace_title');

function my_replace_title(){
    return get_option('my_site_title');
}

The new title is "my website title". But it's out putting the result:

"my website titleTest"

How to replace old title with new title?

share|improve this question
1  
To which title are you referring: 1. Site Title, 2. Page Title, 3. Post Title ? –  Brian Fegter Dec 26 '12 at 21:20
2  
Make sure the Test part is not hard-coded in your theme. –  toscho Dec 26 '12 at 21:21
    
@BrianFegter Site Title –  Seek Php Dec 26 '12 at 21:25
add comment

1 Answer

Please try this code hope it will solve your problem.

add_filter( 'wp_title', 'theme_custom_title', 20 );

function theme_custom_title $title ) {
    return str_replace('your old title', 'your New title', $title); 
}
// changes the "Enter title here" to "Enter some New title" 
add_filter('gettext', 'custom_rewrites', 10, 4);

function custom_rewrites($translation, $text, $domain) {
    global $post;
    $translations = &get_translations_for_domain($domain);
    $translation_array = array();
    switch ($post->post_type) {
        case 'videofaqs':
            $translation_array = array(
                'Enter title here' => 'Enter Video question here'
            );
            break;
    }
    if (array_key_exists($text, $translation_array)) {
        return $translations->translate($translation_array[$text]);
    }
    return $translation;
}
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.