Hi, @cduyvis
Try adding this at the end of the functions.php file of your active theme:
function custom_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return home_url( '/images/' . $post->post_title );
}
add_filter( 'attachment_link', 'custom_attachment_link', 20, 2 );
Be aware that when your theme will update, that piece of code will be lost. Might consider creating a child theme or keep the above code handy
Hope this helps.
Kind regards!
Thank you for your help! Unfortunately, that code doesn’t work. Part of that is because it takes the post title instead of the post slug (which I changed) but more important – the actual attachment page isn’t located at /images/ yet. So this code changes the URL I’m directed to, but the page itself isn’t there, resulting in a 404.
Any clue how to address that problem?