• Hi Guys ??
    This is an unresolved question for many years…
    The creation of the above-mentioned Image Attachment Page created problems to many about SEO… Someone solved With a redirect method…
    But sometimes, something weird can happen:
    I was uploading on the Home page an Image called Services…
    Wordpress created an attachment page called mydomain.com/Services and assigned that to the image just uploaded
    So when I was trying to create the actual page SERVICES i was not able to do that… and that was sad and funny ??

    Anyone knows if it is possible to hack the core of WordPress to avoid the creation of pages that contain the image just uploaded?
    Thank you in advance for your replies ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    If you are going through the media library to add images, then there is no “clean” way to prevent attachments. The best you can do is delete the attachment right after it is created. That would not in itself solve the attachment “stealing” your page name, but that’s not a factor any more. Some revisions back the core was changed to allow different post types to have the same title slug, so both the attachment and your page can now have the same title slug.

    Deleting attachments will break any theme or plugin that is relying on attachment posts for their functionality, so deleting attachment posts may not be the best approach. I’m not sure about the SEO ramifications. With many themes, I don’t see how attachments would matter any. With any theme where it might matter, it’s probably better to alter the theme than core code.

    Thread Starter StelleDiPolvere

    (@stelledipolvere)

    Thanks for reply bcworkz! ??
    Any way to have a different attachment page permalink structure either?

    For example if i’m uploading an image called services into the homepage and that will create an attachment page url at mydomain.com/services/

    Is there any way to have all the attachment pages created while uploading files with a prefix?

    Something that could have this kind of result
    mydomain.com/img-attachments/services/

    where services is the name of the image just uploaded… but at least will not take the url of a future page mydomain.com/services/

    thanks ??

    Moderator bcworkz

    (@bcworkz)

    You can setup custom rewrite rules so URLs like you suggest are possible. You’d also need to filter any permalink output to include the extra prefix. Depending on where these links are generated, this may be easy or difficult to do.

    This would not help any though. You could put a random, meaningless prefix in the URL without any rewrite rule and WP will still find the attachment. By default, URLs to attachment pages are “prefixed” with the post slug that has the image attached to it. It’s only unattached attachments (no joke, it’s a WP thing ?? ) that should have un-prefixed URLs. And if you happen to have both a page and an unattached attachment with the same slug, WP will return the post, not attachment.

    In fact, in such a case, you cannot access such attachments with a normal URL at all, you either have to attach the attachment or use the standard post ID type of request ( example.com/?p=123 ).

    I’m not seeing a problem that needs fixing here. If you have an unattached attachment whose slug is “services”, and its URL is example.com/services/, you should still be able to add a page with the slug “services”. Once you do, example.com/services/ will return the page, never the attachment. If you then attached services.jpg to your /services/ page, the URL to the related attachment becomes example.com/services/services/. (domain/page/attachment/)

    If this is not the behavior you are experiencing and you have a recent WP version, some plugin or theme is altering the default behavior and that should be the subject of your attention.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Disable Creation of Image Attachment Pages for Uploaded Images’ is closed to new replies.