试试这个:在你的函数中。php将此
function fb_excerpt($text, $excerpt) {
if ($excerpt) return $excerpt;
$raw_excerpt = $text;
$text = strip_shortcodes( $text );
$text = apply_filters(\'the_content\', $text);
$text = str_replace(\']]>\', \']]>\', $text);
$text = strip_tags($text);
$excerpt_length = apply_filters(\'excerpt_length\', 55);
$words = preg_split("/[\\n\\r\\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if (count($words) > $excerpt_length) {
array_pop($words);
$text = implode(\' \', $words);
$text = $text . \'...\';
} else { $text = implode(\' \', $words); }
return apply_filters(\'wp_trim_excerpt\', $text, $raw_excerpt);
}
在你的标题中。你们之间的php
<head>
和
</head>
标签放置此
<?php global $post;
if (is_singular()) { ?>
<meta property="fb:admins" content="522774907844630">
<meta property="og:title" content="<?php the_title(); ?>">
<meta property="og:description" content="<?php echo fb_excerpt($post->post_content, get_the_excerpt()); ?>">
<meta property="og:type" content="article">
<meta property="og:image" content="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>">
<meta property="og:site_name" content="<?php bloginfo(\'name\'); ?>">
<meta property="og:url" content="<?php echo(\'http://\'.$_SERVER[\'HTTP_HOST\'].$_SERVER[\'REQUEST_URI\']); ?>">
<?php } ?>