WordPress.org

Forums

Rewrite Attachments Page URL (1 post)

  1. ProStone
    Member
    Posted 10 months ago #

    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

Reply

You must log in to post.

About this Topic