Support » Plugins » Hacks » Rewrite Attachments Page URL

  • Hi,
    how can i change Attachment Pages URL to something like this
    example.com/photos/attachment_ID/post_name/attachment_name
    currently I added on functions.php file the following code

    function wpd_attachment_link( $link, $post_id ){
        $post = get_post( $post_id );
        return home_url( '/photos/' . $post->ID . $post->post_name );
    }
    add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

    source
    but it is showing me as domain.com/photos/Attachment_IDattachment_name
    thank you

  • The topic ‘Rewrite Attachments Page URL’ is closed to new replies.