Answer the question
In order to leave comments, you need to log in
Open Graph vkontakte. How to edit the description when sharing?
Hello, how can I make Vkontakte, when sharing material from the site, set not "Edit description" as in the picture, but the normal description of the article?
in functions.php is:
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');
function insert_fb_in_head() {
global $post;
if ( !is_singular())
return;
echo '<meta property="fb:admins" content="Ваш ID в Facebook"/>';
echo '<meta property="og:title" content="' . get_the_title() . '"/>';
echo '<meta property="og:type" content="article"/>';
echo '<meta property="og:url" content="' . get_permalink() . '"/>';
echo '<meta property="og:site_name" content="' . get_bloginfo('name') . '"/>';
if(!has_post_thumbnail( $post->ID )) {
$default_image = "http://example.com/image.jpg";
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 );
Answer the question
In order to leave comments, you need to log in
I guess I need to add this line:
echo '<meta property="og:discription" content="' . но не знаю что здесь написать, как краткий анонс вывести . '"/>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question