Essentially I have the Yoast plugin handling my SEO related things. The main one giving problems is the description meta tag.

The site is bilingual and I would like the description meta tag to be translated as well. Yoast currently does not provide that option, unless I get another plugin which I do not want to get into.

As it stands, I am told that I can insert the description meta tag through the functions.php using add_action. This unfortunately does not work as it only adds another description meta tag.

Currently my code looks like this:

function insert_meta_tag_in_head () {
    echo '<meta name="description" content="My New content" />';

add_action('wp_head', 'insert_meta_tag_in_head', 1); 

So basically this just gives me a second description meta tag. I have also seen in other threads, that if I want to replace a tag, I should use the do_action function. Which I call as follows:

do_action('wp_head', 'insert_meta_tag_in_head'); 

This however does nothing. What am I doing wrong? How can I change the contents of the description tag given to me through Yoast?

1 Answer 1


Take a look at WordPress SEO API Docs it appears you can modify the meta description tag will somthing like:

add_filter('wpseo_metadesc', function($description){
    if ($wtv_language == 'wtv') {
        $description = "my other language meta description here";
    return $description;

Note that $wtv_language == 'wtv' would need to be replaced with whatever function/variable you're using to detect your language - and "my other language... would need to be replaced with a dynamic translated value, so each page gets a proper translated description, however you plan to do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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