You could achieve that by adding a rewrite endpoint via add_rewrite_endpoint
.
This post from a WordPress developer has a good explanation of how they work.
Related Posts:
- Stop WordPress from reserving slugs for media items?
- Post being redirected to attachment post
- Is it possible to list post attachments in a sub URL endpoint with a dedicated template?
- Attachment page 404 not found when image is attached to post
- Image Attachment Url Rewrite
- How to replace “wp-content/blogs.dir” with “media” for attachment permalinks?
- Adding File Extensions to Attachment Page Permalinks
- Page Attachment Permalink Structure based on Menu Order?
- Custom attachment permalink structure [closed]
- Attachment Page Permalink/URL Rewrite Issue. How to change the actual rewriting?
- Media/attachment urls don’t redirect with fake URL structure
- Remove “attachment/” from the URL of attachment pages
- Post Title to link to a PDF
- Change permalink to attachment
- How do i get post thumbnail using attachment code
- Help me fix these crazy attachment page URLs (rewrite?)
- Is there a way to show attachment IDs on the attachment info screen?
- How do I rewrite attachment urls when permalink structure contains %category%?
- WordPress Attachment Page URL Rewrite!
- get_attachment_link() adds a hashtag to URL
- get_permalink to attachment not working
- Changing permalinks gives me 404 errors on nginx
- Disable Attachment Pages Completely
- Does WordPress automatically do 301 redirect if I change permalink
- Move WordPress to subdirectory, keep ALL URLs
- ‘post_type_link’ filter not working
- Update URL Snippet to Canonical Permalink URL
- WordPress permalinks Yahoo hosting(no .htaccess allowed)
- Permalink: postname EXCEPT for blog
- %tag% in permalink not working
- Change website URL without breaking links or images? WP 3.3
- How to identifty post from its URL in 404 page?
- Rewrite rule never matching
- How to get blog id from permalink?
- Custom url for a single page
- Search result permalink
- Permalinks Structure and 404 Question
- Rewrite URL for results of a custom WP_Query
- Using ‘Primary Category’ in URL
- template_include not loading -instead goes to index.php
- How to link to “most recent” document in the Media Library?
- Permalinks not working
- Need Help Correct Regular Expression Redirect Code
- Why wordpress multisite root site showing blog prefix by force?
- issue with setting up permalink programmatically
- changing permalink for custom template in posts of a certain category
- Force wordpress to display page with same url structure as categories
- WordPress Pages Redirecting to Root with WordPress Multisite (Sub-Directory)
- is there a way to add the post URL to the results of fselect facet in Facetwp plugin?
- NGINX serve WordPress from sub-path fails with 404, how to fix?
- Redirect /%year%/%monthnum%/%day%/%postname% [closed]
- How to get functions.php work with postname permalink?
- WordPress always returning 404 page for a specific url
- Pre-populate Slug / Permalink with URL
- Dynamic Custom Permalinks
- Allow Permalinks to Work with and without Hyphens
- Problems with rewrite rule
- How to Custom Edit Post Title & Permalink Slug?
- Problem with parent page slug only in WordPress admin
- “-2” Being added to end of URL (no duplicate pages, no pages in trash)
- Relative links in Gutenberg
- Post Name Permalink setup gives 404 error inside sub-directory
- Why is my RSS feed not working?
- Convert single apix to dash in permalinks
- Page redirect to 404 when set Permalink = “Post Name”
- How to remove the link of an image on WP 4.2
- How to enable http (not just https) in wordpress?
- Keep permalinks in WordPress
- Need to capture “keyword” added to the end of the post, even with “pretty permalinks”
- Can not manually change the permalink of a post in the EDIT secion
- How to change permalinks to show categoryname/post-name?
- Post with no tag permalink problem
- What permalinks do I use in the redirection
- WP Multisite Subdirectory Custom Permalinks 404
- WordPress’ «post name» setting broken
- Convert $ _GET to permalink
- Permalink blog page (only) not working
- Link to a page before launch
- My WP homepage works, but the other pages don’t when accessing from out side of my network
- CPT links error: each one links to next one further along in the list
- Logging in to installation in subdirectory renders broken dashboard (no CSS, broken links)
- Woocommerce product page 404 not found
- WordPress and NGINX – permalinks are not working with ending slash
- Get value from URL with different types of parameters
- a way to support totally different url structure
- Page permalink redirects to home page
- I have to specifiy port otherwise the website doesnt work
- Permalinks for thumbs with get_post_gallery
- Permalinks/Pretty links aren’t working on my site
- How to hide slug numbers with htaccess
- Once redirected by Rewrite rules, how can WordPress know the page?
- Redirect Pretty Permalinks to Ugly Permalinks
- Slug adding -2 even though the other posts with the same name is in a separate post type
- Strip category base from URL?
- Does the error “A structure tag is required when using custom permalinks.” mean my permalinks haven’t saved?
- WordPress 6.1.1 UTF8 Slug Limit Increase
- 301 Redirect posts to newly added categories
- How to have category/subcategory/posttitle/ permalinks?
- Website appears with wrong permalink in Google’s search
- Permalink settings are stuck on https, will not update to http