2

I need to hide the comments icon on oEmbed widgets or disable the comments icon feature completely. I've been looking at the following links:

https://developer.wordpress.org/reference/files/wp-includes/embed.php/ https://core.trac.wordpress.org/browser/tags/4.5/src/wp-includes/embed.php

What I came up with after thinking for a while was this. I feel its a bit hacky, however it works. I copied the code from the_embed_site_title() and added inline style to display none at the end of it, then hook into with it a filter.

I added .wp-embed-comments{ display: none; } in the last $site_title variable before being returned.

function groovy() {
  $site_title = sprintf(
  '<a href="%s" target="_top"><img src="%s" srcset="%s 2x" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>',
    esc_url( home_url() ),
    esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
    esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
    esc_html( get_bloginfo( 'name' ) )
  );
  $site_title = '<div class="wp-embed-site-title">' . $site_title . '</div><style>.wp-embed-comments{ display: none; }</style>';

  return $site_title;
}
add_filter( 'embed_site_title_html', 'groovy', 10, 2 );

Is there a better way?

1 Answer 1

4

Pretty sure you can just remove them entirely:

remove_action( 'embed_content_meta', 'print_embed_comments_button' );
3
  • Is there a way to remove the entire embed_footer?
    – Libin
    Commented Jan 4, 2020 at 16:06
  • @Libin I'm not sure what you mean, can you elaborate? Commented Jan 7, 2020 at 16:47
  • Hi, I'm trying to remove the entire oembed footer, not just print_embed_comments_button. wordpress.stackexchange.com/questions/355699/…
    – Libin
    Commented Jan 9, 2020 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.