Hello i found this code and I modified a litle, but i have a problem with it. I want the link of the attachment page to be something like this [post-permalink]/[gallery]/[postid] 1234/ .. /1253/ I tried this, the URL is like I want to be but gives me a 404 error: function wpd_attachment_link( $link, $post_id ){ $post = get_post( $post_id ); return get_permalink() . 'gallery/' . $post->ID ; } add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 ); How to do that?