embed - How to disable URL preview in Wordpress comments

admin2025-01-07  3

I disabled URL embed in Wordpress using the following code in functions.php:

function my_deregister_scripts(){
 wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_deregister_scripts' );

The embedded iframe is gone, but the link is still not showing. I only get the page title linked to that URL (and within a blockquote, I don't know why).

How can I simply post a link in Wordpress comments and have it show up as is:

Thanks!

I disabled URL embed in Wordpress using the following code in functions.php:

function my_deregister_scripts(){
 wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_deregister_scripts' );

The embedded iframe is gone, but the link is still not showing. I only get the page title linked to that URL (and within a blockquote, I don't know why).

How can I simply post a link in Wordpress comments and have it show up as is:

http://www.example.com

Thanks!

Share Improve this question asked Feb 23, 2020 at 19:15 AlexAlex 1811 silver badge9 bronze badges 2
  • I'm not sure I understand, WordPress doesn't support OEmbed in comments out of the box. Something on your site perhaps a theme or a plugin has added oembeds to your comments. Normal WordPress does not support embeds in comments. You should look at your plugins and themes and identify which one is adding this behaviour to your site – Tom J Nowell Commented Feb 23, 2020 at 20:44
  • Does this answer your question? Remove link preview in discussion dashboard – Jani Uusitalo Commented Jan 3, 2021 at 12:56
Add a comment  | 

1 Answer 1

Reset to default 0

(Note that this answer deals with URL previewing in the Admin, Comments area. URLs are not 'previewed' in what the visitor sees in your posts' comments.)

If you inspect the source of the Comments page (in Admin, Comment area, where a link will be previewed if you hover over it), you will see that the code is done by the Akismet plugin, which add this CSS (in akismet.css line 42):

table.comments td.comment p a::after {
    content: attr(href);
    color: #aaa;
    display: inline-block;
    padding: 0 1ex;
}

In that CSS, the 'content' attribute of that CSS rule is using attr(href) to display the content of the href.

Never have liked how Akismet does that. It is possible fora link to be malicious and perhaps install malware code (or execute it) on that href link.

You could probably get rid of that preview with added CSS (in Additional CSS in theme customization):

table.comments td.comment p a::after {
    content:none !important;
    display: none !important;
}

I see this default display of links in the Admin, Comments area as a possible malware problem. But when I asked them about it (last year), there was no indication they saw it as a problem. I still don't like it, especially since Akismet is a very common plugin on WP sites.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736263541a899.html

最新回复(0)