Merhaba;
Aşağıda ki kodu functions.php ye ekleyin
// Facebook paylaşımlarımıza da önem verelim dimi
add_image_size('fb-preview', 90, 90, true);
// Öne Çıkarılmış Görseli Aldık
function ST4_get_FB_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id( $post_ID );
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src( $post_thumbnail_id, 'fb-preview');
return $post_thumbnail_img[0];
}
}
// Açıklamayı özet haline getirdik
function ST4_get_FB_description($post) {
if ($post->post_excerpt) {
return $post->post_excerpt;
}
else {
// Kaç Kelime görüneceğini yazdırdık
$excerpt_length = 55;
// Ve yazdırdık daha ne olsun
$text = str_replace("\r\n"," ", strip_tags(strip_shortcodes($post->post_content)));
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
$excerpt = implode(' ', $words);
return $excerpt;
}
}
}
add_action('wp_head', 'ST4FB_header');Ardından header.php dosyanızı açın ilk head etiketinden sonra
<?php
function ST4FB_header() {
global $post;
$post_description = ST4_get_FB_description($post);
$post_featured_image = ST4_get_FB_image($post->ID);
if ( (is_single()) AND ($post_featured_image) AND ($post_description) ) {
?>
<meta name="title" content="<?php echo $post->post_title; ?>" />
<link rel="image_src" href="<?php echo $post_featured_image; ?>" />
<?php
}
}
?>kodlarını ekleyiniz...
Paylaşım yapmak için göstereceğiniz butona da bu şekil de gösterirseniz facebook da sorunsuz içerik paylaşabilirsiniz.
<a href="https://www.facebook.com/sharer.php?u=<?php echo urlencode(get_permalink($post->ID)); ?>&t=<?php echo urlencode($post->post_title); ?>">Share on Facebook</a>