Support » Plugin: WooCommerce » The Update Script Change Attachment Permalink to ?attachment_id={post_id}

  • Resolved Chris Baldelomar


    The update script changed my attachment page permalink from pretty to ?attachment_id={post_id}. For newly uploaded product images, I get a pretty permalink.

    How can I fix my product permalinks back to the original, so they are pretty again?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Just to be clear, it was the database update script.

    Caleb Burks


    Automattic Happiness Engineer

    Hmm, the only thing in the update scripts that has to do with images is this: And that’s not altering the permalinks, just setting to options based on previous ones.

    If you regenerate thumbnails and re-save the permalinks page, does that help?

    I did try regenerating thumbnails. I found out after I tested on another site with products: After I updated the WooCommerce plugin, the permalinks changed for the attachment from pretty to ?attachment_id={post_id}. So the bug is not with the update script.

    Caleb Burks


    Automattic Happiness Engineer

    And re-saving permalinks doesn’t help either?

    WooCommerce doesn’t use attachment permalinks, that’s something WP handles on it’s own I believe. So this is quite strange.

    For new images that are uploaded, and that are attached to a product, the problem continues:

    Recently uploaded and attached product image with ugly permalink.

    Recently uploaded and unattached image with pretty permalink.

    Plugin Author Mike Jolley


    Complex rewrite structures can be broken by attachment URLs. This is from 2014:

    More recently this was rolled out to all permalinks:

    We don’t really have a need for pretty attachment URLs. They are not used anywhere nor linked from product pages. There are no plans to revert this change or support pretty attachment URLs for products.

    If you want to change it on your own site, use:

    remove_filter( 'attachment_link', 'wc_fix_product_attachment_link', 10, 2 );

    This will remove our handling completely.


    Thanks for that information. It just broke Jetpack’s image attachment lightbox on old pretty attachment URL’s. WordPress now reads the old pretty attachment URL as a custom link, instead of an attachment URL.

    At least I know what the problem is. Thanks for the information and quick response.

    In terms of coding philosophy, I do not think it is wise for a plugin to change the behavior of an attachment permalink structure for a specific custom post type attachment page. First of all, it is inconsistent with the rest of the permalink structure for other attachments. Second, the WordPress core should handle how attachment permalinks should display, not a plugin. And third, you do not really know how other people are using product attachment pages. I would be wary about generally assuming that they are not used anywhere. People use WordPress and WooCommerce in many different ways.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘The Update Script Change Attachment Permalink to ?attachment_id={post_id}’ is closed to new replies.