Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här inaktiverar du embeds i WordPress (2 enkla sätt)

Vill du inaktivera post oEmbed på din WordPress website?

Som standard kan alla WordPress-användare embeda dina posts på sin website med hjälp av det built-in WordPress URL block. Andra användare kan också embeda innehåll från tredje part på din website på ett sätt som kan skada din sites hastighet och prestanda.

I det här blogginlägget visar vi hur du inaktiverar post embeds på din WordPress blogg eller website.

How to disable embeds in WordPress

Varför inaktivera embeds i WordPress?

oEmbed är en teknik som allow WordPress användare att embedda content. Du kan till exempel embedda videoklipp i dina blogginlägg i WordPress, visa bilder från webbplatser för sociala medier, visa tweets från X/Twitter eller YouTube-videor med mera.

Embeds kan add to variation till ditt content, men det finns situationer där det kan vara fördelaktigt för din WordPress site att inaktivera dem.

Ett stort problem är webbplatsens prestanda. Embeds kräver en ytterligare HTTP request för att hämta filen wp-embed.min.js. Detta JavaScript kan add to och sakta ner din website, särskilt om du har mycket embeded content.

Att inaktivera embeds kan bidra till att förbättra din websites hastighet att hämta filer och övergripande prestanda.

En annan anledning att överväga att inaktivera embeds är att undvika oavsiktliga trafikspikar. Som standard, om du kan bädda in någons innehåll på din WordPress website, kan vem som helst bädda in ditt innehåll med hjälp av WordPress URL block i gengäld.

How to embed a WordPress page or post

Detta kan vara ett tveeggat svärd. Om en populär site embedar ditt content kan det öka trafiken på din blogg. Men det kan också leda till plötsliga trafikökningar som överbelastar din websites resurser, beroende på planen för ditt WordPress webbhotell.

Slutligen kan det vara en säkerhetsåtgärd att inaktivera embeds. Du kanske har specifikt content, som login pages eller membership areas, som du inte vill ska vara offentligt tillgängligt via embeds. Genom att inaktivera embeds får du mer control över vilket content som visas på andra websites.

Med detta i åtanke, låt oss se hur du kan inaktivera post oEmbed på din WordPress website. Använd bara snabblänkarna under för att hoppa direkt till den metod du vill använda:

Det bästa sättet att inaktivera WordPress post embeds är genom att använda en code snippets plugin.

Genom att använda ett snippet på din website kommer alla som försöker embeda ditt content med hjälp av en link att få en tom page istället. Detta är viss användbart om du runar en online store eller membership site, eftersom det kan hindra folk från att embedda din checkout, login, och andra viktiga pages.

Samma code snippet kommer också att inaktivera embeds på din site, vilket kan förbättra dess hastighet och prestanda.

Det enklaste sättet att add to kod till din website är att använda det gratis plugin-programmet WPCode.

WPCode är det bästa code snippets pluginet för WordPress som allow you to add custom CSS, PHP, HTML, och mer till din WordPress website. Det har också ett färdigt code snippet som kommer att inaktivera embeds på hela din website.

Tänk bara på att detta inte kommer att ta bort något content som WordPress användare redan har embeddat. Det kommer dock att hindra webbplatser från att embeda mer av ditt content.

Först måste du installera och aktivera det gratis pluginet WPCode. För mer information, se vår Step-by-Step guide om hur du installerar ett WordPress plugin.

När plugin är aktiverat, head över till Code Snippets ” Lägg till snippet.

Adding a code snippet to your site using WPCode

Här kommer du att se WPCodes bibliotek med Pre-Made snippets som du kan add to your site. Dessa inkluderar ett snippet som allow you att helt inaktivera comments, upload file types that WordPress doesn’t usually support, disable attachment pages, and much more.

För att hitta rätt snippa skriver du bara ”Inaktivera embeds” i fältet ”Search Snippets”.

Disabling embeds using the WPCode code snippets plugin

När snippet Inaktivera embeds visas, hoverar du musen över det.

Om du inte redan har anslutit dig till biblioteket WPCode snippets kommer du att se en knapp ”Connect to library to unlock”.

Connecting to the WPCode code snippets library

Detta öppnar en popup där du kan skapa ett gratis WPCode-konto och låsa upp över 50 gratis code snippets.

Skriv bara in ditt namn, email address, användarnamn och password. Sedan går du vidare och klickar på knappen ”Registrera”.

Registering for a free WPCode code snippets account

När det är gjort, växla tillbaka till WordPress dashboard och hovera över Inaktivera embeds code snippet.

När det dyker upp måste du klicka på knappen ”Use snippet”.

Adding a ready-made custom code snippets to your WordPress website

Detta hämtar code snippet med all Settings redan konfigurerad. För att göra snippet live, gå helt enkelt vidare och klicka på ”Inaktiverad” slider så att den visar ”Aktiv”.

Du kan sedan klicka på ”Update”.

Disabling the oEmbed feature in WordPress using WPCode

När det är gjort kommer WPCode att add to koden till ditt WordPress temas functions.php-fil och inaktivera embeds på hela din website. Samtidigt kommer snippet att stoppa andra webbplatser från att embedda ditt content.

Vid något tillfälle kanske du vill tillåta embeds på din webbplats eller tillåta andra användare att visa ditt content på sin site. I så fall är det bara att heada över till Code Snippets Code Snippets.

Här måste du hitta snippet för att inaktivera embeds och click för att deactivate dess ’Status’ toggle.

Deactivating a custom code snippet on a WordPress blog or website

Detta inaktiverar code snippet på hela din WordPress website.

Metod 2: Installera tillägget Disable Embeds WordPress

Om du inte vill add to custom code till din website, kan du använda Disable Embeds istället. Det här är ett enkelt plugin utan konfigurationsinställningar, så det inaktiverar WordPress embeds vid aktivering.

Det första du behöver göra är att installera och aktivera Disable Embeds. För mer information, se vår Step-by-Step guide om hur du installerar ett WordPress plugin.

När det är gjort kommer pluginet att inaktivera oEmbed för dina posts på andra WordPress-bloggar. Du kommer inte heller att kunna embedda något innehåll från tredje part från Gutenberg block editor.

Som vi nämnde tidigare, detta innebär inte att your content tas bort från WordPress websites. På grund av hur WordPress caching fungerar, om en tredje part redan har embed en page eller post, kommer den att fortsätta att visas på deras website.

Bonustips för att förbättra hastighet och prestanda i WordPress

Att inaktivera embeds i WordPress kan vara ett bra sätt att öka hastigheten och prestandan på din website. Om du letar efter fler sätt att öka WordPress prestanda, så kan du göra det:

För mer details, you can see our complete guide to WordPress prestanda.

Vi hoppas att den här artikeln hjälpte dig att inaktivera embeds i WordPress. Du kanske också vill se vår guide om hur du embedar iFrame-kod i WordPress eller se vårt expertval av de bästa sökmotorsoptimering (search engine optimization) tilläggen och tools för att hjälpa dig att få mer trafik till din site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

25 kommentarerLämna ett svar

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Jiří Vaněk says

    I’d like to ask a question. Is it possible to disable embeds with exceptions? For example, to disable embeds for everything except YouTube? I’d like to disable embeds in general, but I use YouTube videos on my website, and that’s the only one I need to allow as an exception. Is it possible to achieve this?

    • WPBeginner Support says

      We do not have a specific code to selectively disable embeds at the moment but if we have a snippet we would recommend we will be sure to share!

      Administratör

      • Jiří Vaněk says

        Thank you for your response. I will also try to find a solution. Since YouTube videos are important to me, I would like to do something more for the security of the website. In any case, thank you for your time and response.

    • WPBeginner Support says

      You would want to reach out to the plugin’s support and they should be able to take a look at the cause of the possible issue.

      Administratör

    • WPBeginner Support says

      It would depend on what crawlers you mean but the main goal of this would be to prevent your posts from being embedded using oembed rather than preventing something that crawls your RSS feed

      Administratör

  3. Dave Kinskey says

    Hi. My concern is not whether others can embed my content, but instead, I want to PREVENT iframe embeds by WordPress on my own pages when I include a link to another site. How can I do that?

    I have a problem on one site on which I include a list of links to help people, but one of the links causes a pop-up registration box for the external site in the Safari browser on all Apple devices. If I visit the external page, however, there is no registration pop-up.

    It’s very off-putting and confusing for any visitor to my site to encounter a pop-up registration box from an external site about 5 seconds after loading the page from my site. I would also like the option to block oembeds when I include links to external sites on a page. How can I do that? I haven’t been able to find any way to stop my own site’s pages from including embeds in iframes on my pages. Can anyone offer a solution? Thanks in advance! :)

  4. Grant says

    The caption says ”… and Why You Should Disable it”, but the story says ”There is no harm in leaving it enabled on your website.” I tend to agree with the latter, unless I’m missing something.

    Why would we want to disable a feature that allows someone, who found our content useful, to easily post a nice summary of it on their own site? It seems like there are only upsides to that, unless the new feature has negatives like security holes, or it’s resource-intensive or something.

      • Øyvind says

        ”no downside”.. except the oembed script added by wp_head function shows your site owner username.. The hackers job just got cut in half.

        • WPBeginner Support says

          It does not show username, instead it shows author name. You can edit your WordPress profile and under ’Display Publicly As’ select a user nicename, this could be your first or last name, or a nickname. If you are more security conscious then you can use a username that is even harder to guess.

        • Øyvind says

          The field author_name shows the authors name. But the field author_url ends with the username slug. I have changed nickname in the admin panel and nicename in the db and still it shows the username like this in the json format:

          ”author_url”:”http:\/\/website.com\/author\/username\/

      • M. Qtips says

        Yes, there is most definitely a downside to this bug (this is not a feature, a feature is something you *want*, not something you don’t want that you need to take extra steps to get rid of.) See me other just-submitted comment about how this is aggravatingly interfering with my ability to post code examples on my blog..

    • M. Qtips says

      Um, this is a very stupid feature that should have been opt-in, not opt-out. I run a tech blog, and I am trying to post about apache mod_rewrite rules, and I can’t use URLs in my examples because it keeps ”helpfully” embedding content instead of leaving my posts as I type them, ruining my example code. Totally aggravating.

  5. Chris says

    Thanks for that hint.
    Is there an option to add a code snippet to the functions.php for example instead of another plugin?

    • mensmaximus says

      Rather than adding a lot of code I recommend to block other sites from displaying your content in an iframe which is what the oembed feature does. Add the following lines to your .htaccess file:

      Header set X-XSS-Protection ”1; mode=block”
      Header always append X-Frame-Options SAMEORIGIN
      Header set X-Content-Type-Options: ”nosniff”

      • mensmaximus says

        the comments strip out some code, next try:

        ´

        Header set X-XSS-Protection ”1; mode=block”
        Header always append X-Frame-Options SAMEORIGIN
        Header set X-Content-Type-Options: ”nosniff”

        ´

        • mensmaximus says

          Well, I have no idea how to post a code here. The three lines have to sit between a conditional ”ifModule mod_headers.c” . However lines with ”smaller”/”greater” arrows are filtered out in the comments (i guess this is a html tag strip feature).

        • Doug Wilson says

          Was wondering if someone would mention this. I’d bet a lot of those 404’s are from other sites: search engines following links to removed content, images …

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.