Hi,
you should be able to fix it by enabling support for “thumbnails” in the advert custom post type, adding the code below in your theme functions.php file should do that
add_filter('adverts_post_type', 'my_adverts_post_type', 10, 2);
function my_adverts_post_type($args, $type) {
if($type != 'advert') {
return $args;
}
$args["supports"][] = "thumbnail";
return $args;
}
Hi @gwin, and thanks for the fast support.
It does not seem to work, unfortunately.
When using the Facebook Sharing Debugger, it tells me:
“Inferred Property The ‘og:image’ property should be explicitly provided, even if a value can be inferred from other tags.”
I removed the default image, which came from Yoast, when sharing on Facebook.
It did remove the image, but it’s still not showing the image from the classified advert.
Tried to clear cache, did not help.
Thanks for your help, I apreciate it.
Update: It seems that when users are adding images to the gallery (I’m using WP authors) they only make “galleries”, and are not setting the “featured” image, and therefor it wont display it in og:image.
Is there any way to take the first image of the gallery, and set it as the ‘featured image’?
Hi,
the code i sent in the last message enables WP Featured Images, go to wp-admin / Classifieds panel and edit one of the ads, then check in the right sidebar if there is a “Featured Image” widget, if it is there then the code is working properly.
Now if in the Adverts Gallery you will mark one of the images as featured (with a “Use this image as main image” checkbox), then this image should be used in og:image tag.
Hi,
Yeah, it seems to work as you describe.
The issue is that not any of my users know that function exists, and wil probably never know.
Is there any way to make the first image the default featured image automatically?
And a feature request: Make the first image automatically the featured image. I hope you get me – It’s better to have a featured image, than not having any.