Yoast SEO and Facebook Open Graph Page Title

It’s a recent news: Facebook does not allo anymore to change the title and description of a shared link. This is a bad news for who is used to change the title directly while sharing.

Probably Facebook is focusing in having only one source of information for a shared page, the page itself, to avoid misleading shares where the title of the page is changed to something totally different. Or just to make it easy for Facebook to rescrap and update the shared information.

With Yoast SEO plugin you can change the meta title for Facebook directly in the post but the only thing I’m interested on is to remove the postfix in the title with the site name. Doing this for each post would be impossible, too much work.

And Yoast SEO has not an option where to set the template for the Facebook meta title as for the general meta title.

Anyway there is a simple solution: filtering automatically the generated og:title metatag and remove the postfix, if present.

Few lines of code are required:

The code add a filter to the WordPress SEO generated meta title for Facebook, search the configured separator from the end of the string and remove the postfix. The coude should be enough safe and can be easily added to the functions.php file of your child theme.

If you need a plugin to incorporate this code in your blog, let me know.

My excuses for my bad english but it's the only way I have to communicate with you. Would you suggest a correction? Leave a comment, thank you!

Leave a Reply