You can just look at url, load the file and exit.
That can be done when WordPress loaded its environment, e.g. on 'init'
.
add_action('init', function() {
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), "https://wordpress.stackexchange.com/");
if ( $url_path === 'retail' ) {
// load the file if exists
$load = locate_template('template-retail.php', true);
if ($load) {
exit(); // just exit if template was found and loaded
}
}
});
Note that doing so a real page with slug “retail” can never be used.
This is pretty easy, but also hardcoded, so if you need this for a single page it’s fine. If you need to control more urls, have a look to the solution proposed in this answer.
Related Posts:
- How to create dynamic URLs on WordPress?
- Get parameters and custom page template
- Does WordPress keep track of a post’s URL history and provide automatic redirects?
- Override default url for author pages?
- Using custom/dynamic “slug” for a page
- How to retrieve $_GET variables from rewritten URLs?
- Passing parameters to a custom page template using clean urls
- Custom slug in front of search URL
- Display posts with author in the url with custom post types
- Clash of the rewrites
- Using a page template without a page
- Create built-in pages without creating actual pages
- How to prevent redirection to max 2147483647 for larger values of the page query variable?
- Will references to ugly links automatically redirect to their pretty url permalink?
- how to add prefix to post url structor only
- Why does wordpress still strip my query var?
- Appending numbers to url do not break the link
- Hijacking the URL for filtering
- WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)
- custom htaccess rewrite rule for page
- Tricky URL rewrite with custom values in url
- How to change page URLs to “www.site.com/page” instead of “example.com/blog/page” but keep post URLs as “example.com/blog/post”?
- Add_query_arg + two times the same argument?
- WordPress 404 unless there is a space in url
- Change default URL of image attachment
- redirect 301 old url to new url
- Change WordPress comments url / word
- Add rewrite rule for rewrite endpoint
- Migrating a page to be an article
- How to get “extended” path info from URL in a plugin
- How to check current URL for endpoint in a template file?
- How to perform a query at the URL?
- add_rewrite_rule not working for language specific characters
- Is there a way to create alias without using htacess, permalinks or delving into code?
- Define orderby in url
- Alias ‘wp-content’ directory to something shorter (framework?)
- WordPress .htaccess – route other URLs to another app
- Is there a ‘rake routes’ for wordpress?
- open all .docs in word online
- How to add custom variable in url without redirect?
- Adding pretty query parameters
- Changing RSS feed URL structure
- How to change the main site url on a multisite installation (network)?
- add_rewrite_rule fro html to another url not working
- Preserve Domain Alias
- WordPress redirects non-existing url to existing ones – how to disable
- Prevent WordPress from Rewriting URL for one template
- How to rewrite url wordpress?
- How to building pretty URLs to reflect category hierarchy?
- How do I display only the parent page in the url
- Wildcard forward all posts and pages with few exceptions
- Help with Rewrite Rule for Custom Post Type with Query String
- Create Dynamic SEO Friendly URL for Virtual Page
- A clean custom rewrite rule for weekly archives
- I want to add a new tag to WordPress URL permastruct
- Rewrite rules automatically for pages using specific template
- Add language prefix to permalinks
- Why is WordPress rewriting absolute URLs on staging site to include staging prefix when we manually point them at the live site?
- How to redirect large amount of URLs?
- How to change the Author Slug from Username to Nickname and deal with Special Characters
- Per Page Permalink Structure for Page Post Type
- ngnix Url rewrite doesn’t work
- Understanding the query string after .htaccess rewrite
- URL renaming issue
- Removing “www” from a site URL
- Adding a query string to only one page url
- wordpress url correction
- Pass parameters to static home page brings up index.php latest posts
- Weird characters behind every single link and images
- How to use wp rewrite to hide form action url?
- Using custom url parameters in a page
- How do I get posts to appear at mydomain.com/blog?
- get variable from url?
- remove archive from url :: marketpress
- Show index.php template instead of 404 page template
- add_rewrite_rule with optional parameters
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- How to change search page url so that it still returns a page when there’s no search query specified?
- SEF add_rewrite_rule & add_rewrite_tag not working
- Allowing multiple URLs for same Post
- How to redirect to a login virtual page?
- Problem building an url with argument
- Multiple permalink with and without category for same post
- How do I rewrite URL that has custom parameter
- Param causing 404
- Get custom posts by segment of the URL
- Use Parent Pages for URL Structure without Landing Page
- 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
- Add dynamic url with external page in WordPress
- How to retrive previous Domain URL in Wp
- How to create short urls for sharing and downloadable content?
- URL Rewrite for CPT single posts
- How to stop WordPress creating URLs that don’t exist
- Rename page URL
- Can I exclude a single URL from a rewrite plugin?
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- Lost WordPress website access after changing URL [closed]
- Remove url parameter using wordpress
- WordPress is adding pagination for all pages like www.example.com/page/123. How to remove that?