illabilis
Forum Replies Created
-
Hi
I want to select wich image apears when i share a post on facebook. But with this code, also apear first image….
Please help:)
An exemple post on my blog
https://gasparfoto.ro/2012/05/anca-cipri-sedinta-inainte-de-nunta.html
and the modified code:function AddMetas() {
if (is_single() || is_page()) {
global $post;echo “<meta property=\”og:site_name\” content=\””.wp_specialchars(get_option(‘blogname’)).”\” />\r\n”;
echo “<meta property=\”og:title\” content=\””.wp_specialchars($post->post_title).”\” />\r\n”;
echo “<meta property=\”og:type\” content=\”article\” />\r\n”;
echo “<meta property=\”og:url\” content=\””.get_permalink().”\” />\r\n”;if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘thumbnail’);
echo “<meta property=\”og:image\” content=\””.$thumbnail[0].”\” />\r\n”;
} else {
$imgs = $this->getImages();
if (count($imgs) > 0) {
echo “<meta property=\”og:image\” content=\””.wp_get_attachment_thumb_url($imgs[0]->ID).”\” />\r\n”;
}
}
}
}function getImages() {
global $post;
$imgs = get_children(‘post_type=attachment&post_mime_type=image&post_parent=’.$post->ID);
if (is_array($imgs)) {
return array_values($imgs);
} else {
return array();
}
}function LikeButton($content) {
$options = get_option(‘olussier-facebook-social-plugins’);………………………..etc