通过以下方式解决
function postimage($size = \'thumbnail\', $qty = -1)
{
if (is_single() && !is_home() && !wp_attachment_is_image()) {
global $post;$images = get_children(array(
\'post_parent\' => $post->ID,
\'post_type\' => \'attachment\',
\'posts_per_page\' => $qty,
\'post_mime_type\' => \'image\')
); if ( $images ) {
foreach( $images as $image ) {
$attachmenturl = wp_get_attachment_url($image->ID);
$attachmentimage = wp_get_attachment_image( $image->ID, $size );
echo \'<meta property="og:image" content="\'.$attachmenturl.\'"/>\';
}
} else {
echo "No Image";
}
}
}
add_action(\'wp_head\', \'postimage\');