A
A
Andrey Filimonov2017-03-28 17:57:38
In contact with
Andrey Filimonov, 2017-03-28 17:57:38

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?
4273e35eea7a4b3f90818bd26fb720be.png
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

2 answer(s)
A
Andrey Filimonov, 2017-03-28
@fil_and

I guess I need to add this line:

echo '<meta property="og:discription" content="' . но не знаю что здесь написать, как краткий анонс вывести . '"/>';

W
web_xaser, 2017-03-28
@webxaser

to you in the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question