Can I Change The Contents Of A Description Meta Tag Generated By Yoast In A WordPress Site?

- 1 answer

I am quite new to WordPress so I am not sure how this would work.

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?



We've previously changed a Yoast title before, however, a description is something we have been working on too.

To sum-up the link above:

You need to filter the wpseo_metadesc action in order to display your new description.

add_filter('wpseo_metadesc', 'new_desc_function');