Is it possible to replace ‘attachment’ with another word?

The goal is to replace the word ‘attachment’ in attachment URLs to read another word, so vising an attachment would be like:

site.com/category/article-name/NEW-WORD/attachment-name/

Is this even possible in WordPress? I’m not sure if it would be better to completely replace it (so there is no ‘attachment’ URL) or just add a URL so that both /attachment/attachment-name and NEW-WORD/attachment-name would work (in order to avoid possible problems if WordPress updates something related to attachments).

WordPress helper Milardovich suggested this as one possible way to do it, but it didn’t work for me (the /IMAGE/attachment-name URL just brings a 404, but nicely the attachment/attachment-name still works).

function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return home_url( ‘/images/’ . $post->post_title );
}
add_filter( ‘attachment_link’, ‘wpd_attachment_link’, 20, 2 );

Has anyone done this? or know how?

Read more here:: Is it possible to replace ‘attachment’ with another word?

Leave a Reply

Your email address will not be published. Required fields are marked *