【发布时间】:2018-12-31 15:31:06
【问题描述】:
我在网上搜索过,仍然找不到解决方案。 我在我的 WordPress 上使用了 Yoast SEO,以确保我获得了 Facebook 需要的所有元代码。 我网站上的一篇文章工作得很好,我不确定这两篇文章在代码方面是否有任何区别。
iframely 的工具显示如下:http://iframely.com/debug?uri=https%3A%2F%2Fwww.flyttd.com%2Fus-flight-training-part-1%2F
这是当前网页上显示的元代码:
<meta property="fb:admins" content="DqxdD4X3ZGn" />
<meta property="og:title" content="קורס טיס אזרחי בארה״ב – חלק א׳ - טוּס אֶת הַחֲלוֹם" />
<meta property="og:description" content="פריסת התשתיות המתקדמות, המרחב האווירי הפתוח לרווחה, ואינספור שדות התעופה מכל הסוגים והגדלים, הופכים את אמריקה לגן שעשועים לטייסים. רק כאן תוכלו לפגוש באותו היום ובאותו השדה מבנה של מטוסי קרב, ספינת אוויר, ומטוס קרגו של אמזון, תו״כ שאתם מנסים להנחית את הצסנה המצ׳וקמקת שלכם על המסלול הנכון. וולקם טו אמריקה!" />
<meta name="description" content="פריסת התשתיות המתקדמות, המרחב האווירי הפתוח לרווחה, ואינספור שדות התעופה מכל הסוגים והגדלים, הופכים את אמריקה לגן שעשועים לטייסים. רק כאן תוכלו לפגוש באותו היום ובאותו השדה מבנה של מטוסי קרב, ספינת אוויר, ומטוס קרגו של אמזון, תו״כ שאתם מנסים להנחית את הצסנה המצ׳וקמקת שלכם על המסלול הנכון. וולקם טו אמריקה!" /><meta property="og:type" content="article" />
<meta property="og:url" content="https://www.flyttd.com/us-flight-training-part-1/" />
<meta property="og:site_name" content="טוּס אֶת הַחֲלוֹם" />
<meta property="og:image" content="https://www.flyttd.com/wp-content/uploads/2018/12/catvot-300x162.jpg" />
这是由functions.php中的以下代码创建的
//Adding the Open Graph in the Language Attributes
function add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
//Lets add Open Graph Meta Info
function insert_fb_in_head() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
echo '<meta property="fb:admins" content="DqxdD4X3ZGn"/>';
echo '<meta property="og:title" content="' . get_the_title() . ' - טוּס אֶת הַחֲלוֹם"/>';
echo '<meta property="og:description" content="' . get_the_excerpt() . '"/>';
echo '<meta name="description" content="' . get_the_excerpt() . '"/>';
echo '<meta property="og:type" content="article"/>';
echo '<meta property="og:url" content="' . get_permalink() . '"/>';
echo '<meta property="og:site_name" content="טוּס אֶת הַחֲלוֹם"/>';
if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
$default_image="https://www.flyttd.com/wp-content/uploads/2018/07/mylogo.png"; //replace this with a default image on your server or an image in your media library
echo '<meta property="og:image" content="' . $default_image . '"/>';
}
else{
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
}
echo "
";
}
add_action( 'wp_head', 'insert_fb_in_head', 5 );
Facebook 调试器代码:
Inferred Property
The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.
Missing Properties
The following required properties are missing: og:url, og:type, og:title, og:image, og:description, fb:app_id
【问题讨论】:
标签: wordpress facebook meta sharing