I get content from an external sources via RSS. I've set "canonical" so google knows the content is not original.

However when I post the link of my articles on Facebook, I get the original URL post instead.

How should I edit my WordPress?


Facebook crawls the page when the link is shared in Facebook. Facebook uses a facebookexternalhit user agent when it does so. See Facebook Bot User Agents for a list of full user agent strings it uses. You would need to remove this canonical for this user agent.

To make that happen in WordPress you should be able to edit functions.php with code similar to:

if (preg_match('/facebookexternalhit/i',$_SERVER['HTTP_USER_AGENT'])){
    remove_action('wp_head', 'rel_canonical');

Code sources:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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