You’ll need to write a rewrite rule to parse the URL and pull out the value of gallery-name and gallery-item-name. This will be tricky as there is nothing to distinguish your proposed URL structure from a hierarchical page structure. If you can throw in something that is always the same for all gallery URLs like /gallery/<gallery-name>/<gallery-item-name>/.
Once you have a rewrite rule in place you can hook into the template_include filter, check if your two variables are set and then tell WordPress to include your gallery template.
Shiba Shake has a good tutorial on galleries with custom permalinks
http://shibashake.com/wordpress-theme/wordpress-permalink-add
Related Posts:
- Change the “page” slug in pagination
- Change author base slug for different roles
- Using custom/dynamic “slug” for a page
- Display posts with author in the url with custom post types
- How to seamlessly redirect between different archive and singular slugs?
- How to add dot(“.”) in post slug
- How to change default page slug?
- Handle category name URL rewrite before different post type slugs
- How to change ?lang=cn into /cn/
- custom htaccess rewrite rule for page
- Why is there /index.php/ in all my links? How do I remove it?
- Multiple Permalinks for Same Post
- Adding more pages to author pages
- Using Blog Parent Slug on Blog Posts Only
- Load a template page based on part of slug in wordpress
- Removing “category” from URLs then “add_endpoint()” won’t work…
- How do I change attachment slug from name to id
- Access files at new location using old file paths
- Adding special characters to slug?
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- Preserve old website URL structure after migrating to WordPress
- How to change the Author Slug from Username to Nickname and deal with Special Characters
- How to change custom post type slug
- Disable WordPress from changing URL slug when post is published
- Using URL rewrite to add custom URL for custom post type
- One off rewrite for single post-type slug (show normal page with same URL instead)
- Can’t use a specific custom URL (slug)?
- How to transform multiple parameter URL to clean URL
- Make the home page’s slug visible in the browser’s URL bar
- Trying to add array of paths to post permalink
- Changing the wordpress default search url to something like – …example.com/search?query=keyword
- How to add dot(“.”) in post slug
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- Change author base and slug in author link
- WordPress numeric (yearly) page names / disable yearly archives
- Post & Page with same slug
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- Remove Page Slug from URL
- Needed to change slug to access page
- .htaccess RewriteBase equivalent for WordPress – Passing a URL as a variable without getting a 404
- Pagination posts. Url format
- Change the slug ( url ) to a sequence number starting from 0 in the custom record type?
- Switch WordPress to non-absolute links? [closed]
- Change the Author Slug from Username to Nickname
- Override default url for author pages?
- Rewrite rules not working in WordPress
- How do I add a server-independent external rewrite rule?
- How to prevent redirection to max 2147483647 for larger values of the page query variable?
- How to create the pseudo static rules of the page I created
- how to add prefix to post url structor only
- How do I remove a word from a url in WordPress using .htaccess?
- WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)
- Rewrite Rule for Custom Page with Query Vars in URL
- wp_sanitize_redirect strips out @ signs (even from parameters) — why?
- WP Rewrite the last two parts of the URL
- Change default URL of image attachment
- Rewrite URL to remap WordPress Permalink
- WordPress redirection to get url friendly
- Access $_POST data after redirect
- Change Query String to pretty permalink
- How to add a custom redirect rule for subdomains?
- How to remove WordPress category from URL and have a custom pagination parameter/rewrite?
- rewrite rules for custom post-type with a custom taxonomy
- Remove special characters in a URL
- append url parameters to all links
- Alias ‘wp-content’ directory to something shorter (framework?)
- Is it possible to rewrite URLs in this situation?
- open all .docs in word online
- url rewrite parsing a custom url parameter not working
- How to add custom variable in url without redirect?
- Using category slug in add_rewrite rule
- Adding pretty query parameters
- Pass a comment id through url and append the comment post’s slug in the url
- How to change the main site url on a multisite installation (network)?
- Problem with add_rewrite_rule
- add_rewrite_rule ignoring other params than the “p” param
- optimize wordpress rewrite rule regex
- How to catch Rewrite rules then display a specific post?
- Adding two rewrite rules
- Load an url with minimal/no DB queries
- Login page is redirecting to homepage
- Change custom post type slug from plugin options
- .htaccess rewrite
- Auto generate rewrite rules for multiple taxonomies
- Generating a Rewrite Rule for sSecific Post-Requests from a Submitted Form?
- Change htaccess to redirect to index.php in subfolder
- URL Rewriting for PHP script on an image URL
- Custom rewrite url category
- rewrite url for authors
- How to redirect specific URL to Subdomain
- How to rewrite wordpress urls with index.php in them
- Force search form to go to clean url without multiple redirects
- Rewrite query string to path
- map multiple URLs to display home page without changing URL displayed in browser’s location bar
- WordPress Autocorrect URL / Slugs Does Not Work
- Rewrite API -Adding a parameter before the slug
- Rewrite URL based on home_url
- Replace term archives with static pages
- Why does my URL rewriting only work using two different methods?
- Using a custom 410 page