- Hook into
'404_template'
. (Example) - Fetch all public custom post types where
has_archive
is notFALSE
. - Find the post type’s
has_archive
string and see if it is part of the current request’s url. - Try
get_page_by_title()
with the last part of the requests. wp_redirect()
to the found post’s permalink.exit;
.
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 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
- URL Rewrite and Archive Template Files – Post Type vs. Taxonomy
- Post & Page with same slug
- How to add 2 variable rewrite rule?
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- Custom Post type and Custom taxonomy with URL rewrite worked but template did not
- Remove Page Slug from URL
- Needed to change slug to access page
- Pagination posts. Url format
- URL rewrites af
- Change the slug ( url ) to a sequence number starting from 0 in the custom record type?
- Masking wp-content/themes/name/images to just images directory using htaccess
- How do I remove a rewrite rule?
- Use subdomain for certain urls
- Can I call a custom plugin with a direct URL
- Custom slug in front of search URL
- Clash of the rewrites
- Can ‘numberposts’ be passed in the URL query string?
- Custom post type permalink structure with the category also acting as an archive
- Prepend meta_value to permalink of post
- Tricky URL rewrite with custom values in url
- Search url wp-rewrite after redirect?
- Add a query string to ALL links on site
- How make a multi language routes, with rewrite rules or rewrite endpoints?
- Add rewrite rule for rewrite endpoint
- Issue with using .htaccess to redirect feedburner feed
- ‘rewrite_rules_array’ or ‘generate_rewrite_rules’ for adding custom rewrite rules?
- Custom rewrite not working
- Changing WordPress Address URL disaster
- WordPress 3.9 breaks invalid permalinks.. code fix possible?
- Hide admin login without plugin
- Need help with simple rewrite rule (shouldn’t this be easy?)
- Trying to find the location of a rewrite of the URL query
- “View post” leads to odd URL
- Redirect HTTP to HTTPS for all sub domains (blog posts)
- Get url param no longer works when using add_rewrite_rule
- How to create a URL Rewrite rule?
- How can I redirect product url to category then product url?
- Map secondary domain to other’s virtual subfolder
- adding custom controller called by front-end
- rewrite attachment url with attachment title
- URL Rewrite with Custom Variables
- htaccess rewrite, adding segment to url
- Custom Download Link
- Rewrite /category/cars into /topics/cars
- Archive page for custom post type and custom taxonomy
- Custom Structure permalinks error 404
- how to move another machine or server without dealing with IP
- Add extra optional text to permalink e.g. “-with-*”
- change url for portfolio image
- Use URI suffix as parameter and ignore when resolving page
- Why wordpress rewrite my custom URL?
- Rewrite dynamic URLs as pretty URLs in WordPress functions.php (add_rewrite_rule) – what’s wrong with my code?
- Rewrite rule not working, suspect redirect string
- WordPress index in subdirectory, blogposts in root directory
- Rewrite Url using .htaccess or hook
- Custom taxonomy Rewrite Rule
- Error 404 wordpress redirecting URL
- I want to add one extra field to my URLs, I’m using Rewrite functions but it doesn’t work
- WPNetwork with custom URL Rewrite rules
- WordPress index page is returning 404 and admin page requires /index.php in url
- Stop wordpress to redirecting home page if no page found
- Rewrite URL variable to custom path
- Own code on index.php wordpress theme file, help with the rewrite rules
- Lost WordPress website access after changing URL [closed]
- Rewrite rule to simulate page hierarchy results in 404
- Custom post type Premalinks main page and details page