是,全局post对象已设置为wp_head
被调用。函数体示例this post:
// restricted to singular pages only
if ( ! is_singular() )
return;
// there has to be a featured image set
$thumb_id = get_post_thumbnail_id();
if ( empty ( $thumb_id ) )
return;
// FALSE or array
$image = wp_get_attachment_image_src( $thumb_id );
// nothing found for unknown reasons
if ( empty ( $image ) )
return;
// make sure it is a real url
$src = esc_url( $image[ 0 ] );
// esc_url() returns an empty string for some invalid URLs
if ( \'\' !== $src )
print "<meta property=\'http://ogp.me/ns#image\' content=\'$src\' />";