Hi,
I am using WPForo to create a forum on my site. However, I can't figure out how to add og:image tags using WPForo. 🙂
The plugin generates following tags:
<!-- wpForo SEO --> <link rel="canonical"/> <meta name="description" content="" /> <meta property="og:title" content="" /> <meta property="og:description" content="" /> <meta property="og:url" content="" /> <meta property="og:site_name" content="" /> <meta name="twitter:description" content=""/> <meta name="twitter:title" content="" /> <!-- wpForo SEO End -->
Is there any setting that I can change to generate og:image tag in WPForo?
Thanks.
You should have some image in topic post. This tag is generated once wpForo detects an image in post content. Here is a good topic to see that in action: https://wpforo.com/community/general-discussions/sharing-wpforo-links-on-linkedin/
If you want to have a default og:image for cases when there is no any image in topic posts you can put this code in WordPress theme functions.php file. Just change the red marked image URL to your website/forum logo URL:
function my_default_og_image( $image_url, $type ){
if( $type == 'og:image' && !$image_url){
return 'https://example.com/images/mylogo.jpg';
}
else{
return $image_url;
}
}
add_filter('wpforo_find_image_url', 'my_default_og_image', 10, 2);
How to Easily Add Custom Code in WordPress (without Breaking Your Site)
Thank you very much Robert. 🙂
You are awesome when it comes to resolving WPForo related queries.
Is anyone successfully using Yoast to generate default og:image tags on wpForo pages? I've got Yoast all setup and working across the rest of the site, but for some reason it seems to not want to populate even the default og:image tag there?
Yoast SEO has no chance to work with wpForo, because wpForo doesn't based on custom post types. Thus wpForo comes with its own built-in SEO features. wpForo generates "og:image tags" on topic page if the topic contains some image in topic post. This tag is generated once wpForo detects an image in post content. Here is a good topic to see that in action: https://wpforo.com/community/general-discussions/sharing-wpforo-links-on-linkedin/
If you want to set a default image for all forum pages you should use this code in your WordPress theme as it explained in my replay above: https://wpforo.com/community/how-to-and-troubleshooting-2/wpforo-is-not-genereating-ogimage-tags/#post-16386