Support » Plugin: OG » og:description Length

  • Resolved cnxsoft

    (@cnxsoft)


    I can see you used to limit the length of og description length @ https://wordpress.org/support/topic/og-description-cut-off-and-wrong-og-image/

    But you removed it, and now the code looks like:

    ` if ( has_excerpt( $post->ID ) ) {
    $og[‘og’][‘description’] = strip_tags( get_the_excerpt() );
    } else {
    $og[‘og’][‘description’] = strip_tags( strip_shortcodes( $post->post_content ) );
    }`

    I thought my post had an excerpt, but apparently not and the full post is used in the description. I guess I should add a filter in my functions.php

    with something like

    add_filter('og_og_description_value', 'my_og_og_description_value');
    function my_og_og_description_value($description)
    {
        /* some code here */
        return $description;
    }

    But I’m not quite sure what some code here should be…

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcin Pietrzak

    (@iworks)

    Hi!

    To trim length to 55 words (default for wp_trim_word() you can use this code:

    add_filter( 'og_og_description_value', function( $value ) {
        return wp_trim_words( $value );
    });

    Marcin

    Thank you very much. It does the job.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘og:description Length’ is closed to new replies.