Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



WordPress - YOAST S...
 
Share:
Notifications
Clear all

[Solved] WordPress - YOAST SEO - Force Featured Image only for Facebook Thumbnail

2 Posts
1 Users
0 Reactions
1,525 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Yoast SEO - a highly recommended plugin for WordPress - has the ability to add tags for Facebook posting of your links (social tab).

The downside is that it pulls in all images of your post, not just the featured image.
If you're like me, and you're WordPress setup uses featured images for posts, then the following code, added to functions.php, will limit the selection to just the featured image:

function mysite_opengraph_content($val) {
    return preg_replace("/<img[^>]+>/i", "", $val); 
 }
add_filter('wpseo_pre_analysis_post_content', 'mysite_opengraph_content');

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Tip: For testing your webpage concerning the Facebook tags, try this debug link:

https://developers.facebook.com/tools/debug


   
ReplyQuote
Share: