Haben Sie schon einmal in WordPress auf ein Bild geklickt, um dann ein einsames Bild auf einer leeren Seite zu sehen? Das ist eine Seite mit Bildanhängen, und das ist nicht gerade ein einladender Anblick für Ihre Besucher.
Diesen Standard Seiten für Anhänge fehlt oft der Kontext, was zu einer schlechten Benutzererfahrung führt und Ihrer Suchmaschinenoptimierung schadet. Die gute Nachricht ist, dass Sie diese Seiten leicht deaktivieren können, wie wir es auf WPBeginner tun.
Sie können sogar ein flüssigeres Browsing-Erlebnis erstellen, indem Sie die Besucher zu einem relevanteren Ziel umleiten, z. B. zu dem Blog-Beitrag, in dem das Bild veröffentlicht wurde.
In diesem Artikel zeigen wir Ihnen, wie Sie Seiten mit Anhängen von Bildern in WordPress deaktivieren und auf den übergeordneten Beitrag umleiten können. So verwandeln Sie diese Sackgassen-Seiten mit Bildern in Gelegenheiten zum Engagement.
Warum sollten Sie Seiten mit Bildanhängen in WordPress deaktivieren?
Standardmäßig erstellt WordPress eine einzelne Seite für jeden Medienanhang, den Sie auf Ihrer Website haben. Dazu gehören Bilder, Audio- und Videodateien, PDFs und mehr.
Einige Benutzer mögen diese Funktion nützlich finden, aber die meisten WordPress-Websites benötigen sie nicht.
Für Fotografen können zum Beispiel Anhangsseiten nützlich sein. Ein Fotothema könnte die Anhangsseite nutzen, um EXIF-Daten anzuzeigen. Diese könnten das verwendete Kameramodell, die Kameraeinstellungen und sogar die Standortdaten des Bildes anzeigen.
Viele WordPress-Blog-Besitzer verlinken ihre Bilder versehentlich mit den Anhangsseiten statt mit dem Bild selbst, oder es gefällt ihnen nicht, wie es aussieht, weil viele Themes keine speziellen Vorlagen für die Bildanhangsseiten haben.
Manchmal wird ein Bild auf Ihrer Website so populär, dass Besucher direkt von Google auf die Seite mit dem Anhang geleitet werden. Im Idealfall möchten Sie, dass die Besucher auf Ihrem Beitrag landen und das Bild in dem Kontext sehen, in dem Sie es verwendet haben.
Um dieses Problem zu lösen, zeigen wir Ihnen zwei verschiedene Möglichkeiten zur Deaktivierung von Seiten mit Bildanhängen in WordPress, damit Sie die für Sie beste wählen können:
Methode 1: Deaktivieren von Bildanhangseiten in WordPress (mit einem Plugin)
Der einfachste Weg, Seiten mit Bildanhängen zu deaktivieren, ist die Verwendung von All in One SEO (AIOSEO). Es ist das beste SEO-Plugin für WordPress und wird von über 3 Millionen Websites verwendet.
Als Erstes müssen Sie das kostenlose All in One SEO-Plugin installieren und aktivieren. Lesen Sie dazu unsere Anleitung zur Installation eines WordPress-Plugins.
Sobald das Plugin installiert und aktiviert ist, haben Sie einen neuen Menüpunkt namens „All in One SEO“.
Navigieren Sie zu All in One SEO “ Search Appearance. Klicken Sie dann auf die Navigationsregisterkarte „Bild-SEO“.
Die erste Einstellung ist „URLs von Anhängen umleiten“. Sie können die Einstellung vollständig deaktivieren oder auf die Anhangsseite oder die übergeordnete Seite des Anhangs umleiten.
Wir empfehlen eine Weiterleitung auf die Seite „Attachment Parent“. Wenn ein Nutzer auf der Seite mit dem Bildanhang landet, wird er stattdessen zu Ihrem Artikel weitergeleitet.
Hinweis: Wenn ein Medium oder ein Bild keine übergeordnete Seite hat, d.h. wenn es nicht in einen Beitrag oder eine Seite hochgeladen wurde, zeigt AIOSEO die Anhangsseite des Bildes an.
Sobald Sie Ihre bevorzugte Einstellung ausgewählt haben, klicken Sie einfach auf „Änderungen speichern“, bevor Sie den Bildschirm verlassen.
Methode 2: Deaktivieren von Seiten mit Bildanhängen in WordPress (mit einem Code-Snippet)
Eine weitere Möglichkeit ist das Hinzufügen eines Codeschnipsels zu WordPress. Wir raten davon ab, Ihre WordPress-Dateien direkt zu bearbeiten, daher werden wir für dieses Tutorial WPCode verwenden.
Um loszulegen, müssen Sie das kostenlose WPCode-Plugin installieren. Weitere Einzelheiten finden Sie in unserer Anleitung zur Installation eines WordPress-Plugins.
Nach der Aktivierung müssen Sie in Ihrem Admin-Dashboard auf Code Snippets “ Snippet hinzufügen gehen.
Geben Sie dann einfach „Anhang“ in das Suchfeld ein. Auf der rechten Seite sollte ein Ausschnitt mit dem Titel „Disable Attachment Pages“ (Seiten mit Anhängen deaktivieren) erscheinen.
Wenn Sie den Mauszeiger darüber bewegen, klicken Sie auf die Schaltfläche „Snippet verwenden“.
Sie werden zur Seite „Snippet bearbeiten“ weitergeleitet, wo alle Einstellungen automatisch vorgenommen werden.
Sie müssen nur den Schalter auf „Aktiv“ stellen und auf die Schaltfläche „Aktualisieren“ klicken.
Wenn ein Nutzer nun auf die Seite mit dem Bildanhang gelangt, wird er zum übergeordneten Beitrag weitergeleitet. Wenn es keinen übergeordneten Beitrag für das Bild gibt, wird der Nutzer auf die Homepage der Website weitergeleitet.
Wir hoffen, dass dieser Artikel Ihnen geholfen hat, Seiten mit Bildanhängen in WordPress zu deaktivieren. Vielleicht interessieren Sie sich auch für unseren Einsteiger-Leitfaden zur Bild-SEO und unseren Leitfaden zur Behebung häufiger Bildprobleme in WordPress.
Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.
Syed Balkhi
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!
SHUBHAM GARG
Why don’t you update this article ?
Yoast doesn’t have this feature in free version anymore.
WPBeginner Support
We are updating our articles as fast as we are able. For the moment you may want to check under Search Appearance > Media
Admin
Dave
My Yoast SEO does have this option under MEDIA. It is the first option, and it says Yoast suggests YES to „Redirect attachment URLs to the attachment itself?“
March 2021 is when I checked.
Abhishek
i post images and link them to media file on my site
should i disable the attachment media pages?
if i do, will it affect seo?
WPBeginner Support
That would depend on your personal preference and if the main content of your site is images rather than posts and pages.
Admin
Tommy
Thank you! For some reason I have never experienced this issue using yoast until today! One of my sites kept redirecting to the image instead of my attachment page. Wasted an hour trying to figure out if it was a function issue I had created. Turns out it was the Yoast plugin. Easy fix thank yoU!
Esther Roche
Hi
Yoast has now changed all the settings, they keep doing this and honestly they’re driving people mad.
This „Redirect attachment URL to parent post“ was very handy and understandable, but now it doesn’t exist.
Instead, we have a Media tab where the instructions seem, at least for me, a bit unclear. This is the explanation they give:
When you upload media to WordPress, it doesn’t just save the media, it creates an attachment URL for it. These attachment pages are quite empty: they contain the media item and maybe a title if you entered one. Because of that, if you never use these attachment URLs, it’s better to disable them, and redirect them to the media item itself.
What this seems to provoke is that now Google is showing image attachment URLs in the SERPs results. But there is no option, as before, to redirect the attachment URL to the parent post. What do we do then?
Am I not understanding correctly the use of the new Media tab? What should I do so that Google doesn’t show those attachments as results in the SERPs that are not image search? Am I not understanding correctly the use of the new Media tab? What should I do so that Google doesn’t show those attachments as results in the SERPs that are not image search? What is it that I’m getting wrong?
H E L P!!
Sevda
Hi Esther,
The current function in Yoast removes the attachment urls by redirecting them to the direct url of the media file (instead of to the parent post). If you are turning it on just now, it’s normal to still have attachment page urls in the index. Selecting the option would lead to the attachment urls eventually disappearing from search engines‘ indexes and being replaced by the media files‘ direct urls (blabla.jpg for example).
If you want to speed up the removal of the attachment urls, you can do so in Google Search Console.
Max Dai
This post needs an update because Yoast has made a lot of changes to its features on new update.
Amanda Formaro
I agree. Not only did Yoast update, but they also removed the very option you are recommending in this post (unfortunately). And now all that’s left is to redirect to the actual attachment.
Colin
The link is out of date now as the permalinks can be found under Advanced on the latest version.
Thanks anyway as I have just updated it.
Jeff
So if we aren’t linking to these attachment pages, is there really any reason to redirect these so google doesn’t index them? The reason I ask is for videos directly uploaded, we have the transcript in the description field so google indexes that.
If we redirect would it still index that transcript or should I leave as is?
beginner
i was using all in one seo plugin and i found „Redirect Attachments to Post Parent:“ in my seo General settings, and i mark it.
So, is that same and worked?
WPBeginner Support
Yep, its the same.
Admin
javidan
hi
witch one is better for SEO
nofollow no index or disable ?
thank you
Pedro
Thank you SO much! This simple thing helped me a lot.
Michael Peters
Question: How can I keep WP from creating an attachment in the database?
What I mean is that I have roughly 40k actual posts, and over 100k rows in the wp_posts table. After running a query, it seems that there is ~100k posts with post_type „attachment.“ Are all of these rows necessary?
Mem
Thanks exactly what I was looking for. I use yoastSEO so it was a single click.
Sam
Thank you dude
Ben
Or You can write this line on robots.txt
Disallow: /wp-content/uploads/
Ajit
Thank you, yes I done, very helpful topics, thank you again
Laurence Cope
But how do you actually disable attachment pages? This post doesn’t disable them but puts a redirect in place. We have issues where the redirects is conflicting with actual page names. We dont want any attachment pages and therefore no need for redirects.
paul
I would like to keep the attachment pages but within the attachment pages that display the image in a bigger size to disable links to prev next and full size image as this is where they can copy images or see images that I dont want non registered users to see etc. How can we do that?
Whitney
Oh wait, I just realized something… if I no index the media files, does that mean all my media is not indexed or just the attachment pages?
Whitney
Is the duplicate content issue only solved if I „no index“ the pages or will the 301 redirect to parent take care of that too? I’m assuming I’d need to no index them…. but just want to make sure I’m assuming right
Muhammad Furqan
Hello i also disabled attachments pages in sitemap. will this technique prevents google to index images?
WPBeginner Support
If the images appear in posts as well, then no it will not stop Google from indexing images.
Admin
Sophia Martin
Thanks for the quick help, it fixed things at once!
Thanks again!
Devdiz
Thanks alot
marco
Great solution!
May I add that after the modification on Yoast I had to go to Settings->Permalinks and save settings (no need to change anything).
Your mileage may vary, this worked for me, thanks!
Stef
It seems Yoast has changed things and this no longer works. Or something is stuck in cache.
Jodi
I’m having the same issue and I don’t think it’s the cache. I installed the plugin mentioned and that works fine.
Adrian Thompson
I had to go to Settings > Permalinks and click Save Changes (without making any changes) in order for it to work after the Yoast setting change.
Hope it works for you.
Hicham
Hi,
Please how to create image.php ?
Thank you
Henry
A nice informative article but oh my what a misleading title!
The post title and the last sentence (after the comma) of the first paragraph are totally off!!!
This is NOT disabling attachment pages/nor stopping WP from creating them (as the title implies) but redirecting links to it to somewhere else, and that is something real different!
Disabling is stopping some from to be happen, and whatever code is shown in this article (even used by named plugins) it is not stopping WP from creating these attachment pages. This article is about how to redirect , which is okay ofcourse but not as implied by the post title and article as it. Such a shame because that would be a scoop!
Jesse
Henry has pointed out an important distinction.
I am building a site that requires members to upload sensitive/private information via registration form. We absolutely can not have these files accessible to the public and need minimize any chance that these files will be indexed and publicly visible. Preventing the creation of attachment pages would seem the way to go, but I supposed redirects would work as well. We wouldn’t want to outright disable all attachment pages as we do want some uploaded files to be indexed, however, as WP Beginner Support pointed out, these files can still be indexed if they are contained within other posts.
Think I will try enabling the attachment page redirects via Yoast SEO plugin as well as change the default directory where registration form uploads are stored (ie. will no longer be in default ‚/uploads‘ directory) and disable indexing of that directory via robots.txt.
Thoughts?
Angela
Hi, thanks for the info!
What about older images which were previously indexed by Google?
I have had the setting on in Yoast for „redirect attachments“ for at least 6 months now, but my older images are still being found.
What would anyone recommend to do with these images? It concerns me because I get some critical errors on the ahrefs tool:
duplicate title tags
duplicate meta descriptions
Shall I just go and add all the tags?
Simon G.Proudfoot
Putting the line in my image.php file worked perfectly. It was giving me a bad SEO score beforehand as the links to the images weren’t mobile friendly. This has fixed it. Thanks
Priyanka Biswas
Glad I found this article. Was wondering why Google was showing all my image attachment pages in the search results. This helps! Thank you.
Raleigh Leslie
Thanks this post helped me explain to someone why you would want to redirect media attachment pages to the actual post of page containing to media. re: „Sometimes an image on your website can become popular and people might start landing on the attachment page directly from Google. Ideally you would want them to land on your post and see the image in the context you have used it.“
Word!
sam
mine is already checked but doesn’t work, all my images redirected to an other page
Tim Brugman
Thanks for the code. I made a slight adjustment so pages for media uploaded to the library directly, not a post, will redirect the visitor to the homepage. Feel free to use this: https://gist.github.com/anonymous/e4f48a41192b4d64fdf3
Catherine
Thank you so much for helping me solve the problem of image attachments. I inserted the code
post_parent)); ?>
into my image.php file and it worked like a charm.
So will Google now de-index my attachment page url’s?
Chris Cox
Ok. Using the php code (no plugin) what happens if there are two pages/posts using the same image?
ashar
I just checked the redirect in SEO as these things were driving me nuts. so glad I found you. thanks – best ashar
Tonya
Thank you! This was an excellent tip, just what I needed to help clean up errors found by Google.
Jorge Pinto
I tryed the code you suggest, it works with the images associated with posts os pages, but.. all the other images uploaded that are no assigned to any post, for that images your code does not work.
Ogier Schelvis
I also had this issue. The Yoast! setting seemed to be ignored. Whether or not it was cache, I like the fact about the image.php solution that you have more freedom to determine what is going to happen. I just wanted to show a 404 for example if the post parent was not set. I solved it like this:
if($post->post_parent != 0):
wp_redirect(get_permalink($post->post_parent));
else:
$wp_query->set_404();
status_header(404);
nocache_headers();
include( get_query_template( ‚404‘ ) );
endif;
philip
Hello a user called Sam posted this issue – You write “Simply check the noindex, nofollow tag for ONLY the attachment post type.” but I do not see such an option. Are you referring to the “media” section? If I click no index under media will that no index my images or attachments? I would like to no index my attachments but I don’t want to lose traffic from Google images.
I would also like to know the answer as I have the same issue
thanks
philip
WPBeginner Support
Philip, no this should not affect your Google Image Search traffic as the option redirects users landing on attachment page to the parent post URL where your image is available for search engines to index.
Admin
Jess
Is it ok to delete the attachment posts in phpMyAdmin?
WPBeginner Support
No, you are not supposed to delete data directly from your database.
Admin
karen
I tried adding the code you have given to my image.php file and it worked beautifully. thank you!
Sam
You write „Simply check the noindex, nofollow tag for ONLY the attachment post type.“ but I do not see such an option. Are you referring to the „media“ section? If I click no index under media will that no index my images or attachments? I would like to no index my attachments but I don’t want to lose traffic from Google images.
Elektra
thanks so much for posting! very useful info and straight forward! appreciated!!
Mark Law
Thanks for the heads up, I got a bit of a shock when I saw absolutely everything had been indexed, including elements of the template such as image backgrounds and so on. I’m using Yoast so it is an easy fix – I wonder though if it is worth still having pdf attachment pages indexed – I’ll look into it.
WPBeginner Support
It takes users directly to the PDF, if that’t what you want then yes sure.
Admin
Junaid Abbas
Is this possible to stop attachment pages to be indexed??? I do not want to redirect them to the home page. I just want to stop indexing them.
Mark
I love the Internet, within 2 mins of discovering an issue, I had found this post and resolved the problem! Thank you wpbeginner.com
Shannon
Will this also fix the issue with creating duplicated content where the image holds the same title as the associated post?
Editorial Staff
Yes.
Admin
Bruce Simmons
Heads up about the plugin… if you use the gallery option to present images in a post, the plugin blocks the function and clicking on an image brings the user back the thumbs index of the images.
-Bruce
Sharon Rigano
Thank you for this article. It has come just at the right time as I was trying to work this one out. Turns out it is a simple solution.
yogesh
Thanks! This is a very useful tutorial.
Ahmad Raza
Thanks for the tutorial. I became victim of Google Panda just because of indexing of alot of attachment pages from my photo blog.
Is there any way to no index only attachment pages (not images) from Google?
Because i have a photo blog and i don’t want to redirect my photos to main posts.
Alex
Ahmad Raza, here’s soulution for you
1 || is_author() || is_tag() || is_date() || is_attachment()){
echo “;
} ?>
You can add just this:
<?php if( is_attachment()){
echo '‘;
} ?>