if i try to publich my website on Facebook i have an error with the featured image.
I try to use the facebook debug but i not have any interest information.
I use this function but nothing resolve:
//* FACEBOOK *//
function insert_fb_in_head() {
global $post;
if ( !is_singular()) // Se non è un post o una pagina
return;
$mytext=$post->post_excerpt;
$myfulltext=strip_tags($post->post_content);
if(strlen($mytext) > 250) $mytext = substr($mytext, 0, 250).'...';
if(strlen($myfulltext) > 250) $myfulltext = substr($myfulltext, 0, 250).'...';
if(empty($post->post_excerpt)) {
$mytext=$myfulltext;
}
$mydesc=$mytext;
$external_posts=$post->ID;
echo '<meta property="fb:admins" content="IDPAGE" />';
echo "\n";
echo '<meta property="og:title" content="' . get_the_title() . '" />';
echo "\n";
echo '<meta property="og:type" content="article" />';
echo "\n";
echo '<meta property="og:description" content="' . $mydesc . '" />';
echo "\n";
echo '<meta property="og:url" content="' . get_permalink() . '" />';
echo "\n";
echo '<meta property="og:site_name" content="TITLE WEBSITE" />';
echo "\n";
echo '<meta property="og:locale" content="it_IT" />';
echo "\n";
$myurl = wp_get_attachment_image_src( get_post_thumbnail_id($external_posts), 'thumbnail' );
$postimage=$myurl[0];
if(empty($postimage)) {
$default_image="URLIMAGE";
echo '<meta property="og:image" content="' . $default_image . '" />';
}
else {
$default_image=$postimage;
echo '<meta property="og:image" content="' . $default_image . '" />';
}
echo "\n"; echo "\n";
}
add_action( 'wp_head', 'insert_fb_in_head', 1 );
So i don't know how can i do to set a specific image. Thanks