Notifications
Clear all

wpForo 1.x.x My forum share button is selecting a particular image thumbnail for all the post,topic discussions

9 Posts
4 Users
0 Likes
2,108 Views
HertzElectroz
Posts: 4
Topic starter
(@hertzelectroz)
New Member
Joined: 4 years ago

please how can i fix this error in my site, please can anyone help

Topic Tags
8 Replies
Robert
Posts: 9912
Admin
(@robert)
Support Team
Joined: 7 years ago

Please leave your website URL to allow us check it. And provide an example.

Reply
1 Reply
HertzElectroz
(@hertzelectroz)
Joined: 4 years ago

New Member
Posts: 4
Robert
Posts: 9912
Admin
(@robert)
Support Team
Joined: 7 years ago

You don't have any image in topics and posts so it selects first found image from your website. This is normal. wpForo detects images in topic first post content when you try to share a topic and it sets found first image as share image. Here is a good topic to see that in action: https://wpforo.com/community/general-discussions/sharing-wpforo-links-on-linkedin/

For non-topic (forum home, forums and other) pages and for topics without an image wpForo allows to set default share image.  That's the default share image (og:image share tag) . You should put this code in WordPress theme functions.php file to set it. Just change the red marked image URL to your website/forum logo URL or to something else, it'll be the default share image:

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)

 

 

Reply
IlliniPulse
Posts: 23
(@illinipulse)
Eminent Member
Joined: 3 years ago

Searching through the help forum and ran across this topic.

Is there a way to share a specific image from a post to Twitter/Facebook, or only the default option above?

Reply
IlliniPulse
Posts: 23
(@illinipulse)
Eminent Member
Joined: 3 years ago
Posted by: @robert

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);

I entered this into my child theme (after changing the image example to my own) and it doesn't work.  Any ideas?

Reply
1 Reply
IlliniPulse
(@illinipulse)
Joined: 3 years ago

Eminent Member
Posts: 23

I put into my main theme functions.php and it still didn't work.  I get this:

Reply
Page 1 / 2