I'm having an issue with url rewriting for a theme I'm making, which is basically a gallery theme based on the roots theme. Here's how the site navigation works:
- Home Page (With Tiled Image Gallery) (Images link to parent pages) Current URL -
domain.com
- Parent Page (With Tiled Image Gallery) (Images link to attachment page along with #id to link to the clicked image ). Current URL -
domain.com/landscapes
- Attachment Page (With ALL full size images attached to the parent post). Current URL -
domain.com/landscapes/image-title/#id
What I would like to do is to remove the image title from the attachment page URL and replace it with gallery so that the URL reads domain.com/landscapes/gallery/#id
My content-image.php uses wp_get_attachment_image_src()
to get the image urls. With pretty permalinks disabled i get an image URL like domain.com/index.php?attachment_id=205
When checking with pretty URL with the Rewrite Rules Inspector Plugin, that URL (domain.com/landscapes/image-title/#id
) gets 2 matches which are as follows:
RULE 1: (.?.+?)(/[0-9]+)?/?$
Rewrite 1: index.php?pagename=$matches[1]&page=$matches[2]
RULE 2: [^/]+/([^/]+)/?$
Rewrite 2: index.php?attachment=$matches[1]
From what I understand, The second rule is the one that is being applied in this case, but I have no clue what to change it to. Any idea on how to do this?