Support » Plugin: Smart Recent Posts Widget » URL IN POST EXCERT

  • Resolved Dono12

    (@dono12)


    Great work,
    all is well with your new plugin (Smart Recent Posts Widget). but the link to YouTube videos are being shown in the post excerpt, only on bbPress Forum pages. Try installing the bbPress Forum Plugin and create a post using a YouTube video link and visit the bbPress Forum page and you’ll see. The link for the YouTube video located in the post is being pulled into the excerpt portion of sidebar widget.

    To Duplicate issue:

    1. Install bbPress https://bbpress.org/

    2. Create Forum and Topic

    3. Add Video Post in WordPress (Add New Post) using a Youtube URL eg: https://www.youtube.com/watch?v=TaUdZ8WmGWs

    4. Add any featured image to Post

    5. Visit bbPress page and you’ll see the raw URL for the Posted Video being Shown in the sidebar widget excerpt.

    • This topic was modified 4 years, 1 month ago by Dono12.
Viewing 1 replies (of 1 total)
  • Thread Starter Dono12

    (@dono12)

    Figured out a solution, I understand you’re busy so I did some digging and found that placing this piece of code in: includes -> functions.php will remove the URL showing in the sidebar. Hopefully you can take care of it in your next update.

    function remove_url_from_excerpt( $text ) {
        if ( '' == $text ) {
            $text = get_the_content('');
            $text = strip_shortcodes( $text );
    
            $text = preg_replace( '~http(s)?://[^\s]*~i', '', $text ); // removes URLs
    
            $text = apply_filters( 'the_content', $text );
            $text = str_replace(']]>', ']]>', $text);
            $excerpt_length = apply_filters( 'excerpt_length', 20 ); // default: 55
            $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );
            $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    	}
        return $text;
    }
    
    remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
    add_filter( 'get_the_excerpt', 'remove_url_from_excerpt');
Viewing 1 replies (of 1 total)
  • The topic ‘URL IN POST EXCERT’ is closed to new replies.