• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Show Videos in WordPress Post Comments

By default, adding the embed code or a link to a YouTube video in a comment form, won’t display your video because the oEmbed discovery for video tags is disabled.

To enable oEmbed discovery for video tags in WordPress comments, you need to add PHP code to your child themes functions file.

add_filter( 'comment_text', 'enable_video_in_comments', 0 );
function enable_video_in_comments( $comment ) {

add_filter( 'embed_oembed_discover', '__return_false', 999 );

$comment = $GLOBALS['wp_embed']->autoembed( $comment );

remove_filter( 'embed_oembed_discover', '__return_false', 999 );

return $comment;
}

Uses embed_oembed_discover wrapped in the comment_text filter.

The Jetpack plugin by Automattic includes shortcodes to do this however you need to add them every time you want to embed a video in a comment.

Once you add this code in your child themes functions.php file, you can simply drop a link to your video in the comments and WordPress will parse the video tags to display your video.

Comments Video

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags