You shouldn’t need to manually handle this with hooks & custom slug settings – just ensure hierarchical
is set to true
in your register_post_type
arguments.
You mention “CPT UI” settings, are you referring to the Custom Post Type UI plugin? If so, make sure Hierarchical is set to True in the Settings metabox.
Related Posts:
- Change the “page” slug in pagination
- How to change default page slug?
- Multiple Permalinks for Same Post
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- 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)?
- WordPress numeric (yearly) page names / disable yearly archives
- How to create custom URL routes?
- How do you create a “virtual” page in WordPress
- Understanding add_rewrite_rule
- web.config conflict on IIS
- Change author base slug for different roles
- Using custom/dynamic “slug” for a page
- Rewrite rules not working in WordPress
- Dynamic Endpoints
- How to add custom rewrite rule to .htaccess?
- How do I remove a rewrite rule?
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?
- add_rewrite_rule: $matches var not replaced by captured value
- Display posts with author in the url with custom post types
- How-to add rewrite rules to point the uploads folder to a subdomain
- Rewrite Rules for Multiple (more than 2) Taxonomies
- How to seamlessly redirect between different archive and singular slugs?
- How to add dot(“.”) in post slug
- add_rewrite_rule not loading correct page nor getting variables
- Preserving $_GET parameter while using custom Rewrite Rule
- Disable wordpress pagination URL rewrite for specific page
- How to use Post Custom Metadata in Post Titles and Post Permalinks
- Handle category name URL rewrite before different post type slugs
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- rewrite_rule() not preserving the query string
- Need help with rewrite_rules_array
- SEO Friendly URLs for my plugin categories
- How do I add a add_rewrite_rule without it redirecting?
- Taxonomy rewrite question
- Mod_rewrite delete parameter in 301 Redirect
- add_rewrite_rule not working for page var
- Why does wordpress still strip my query var?
- When to call `add_rewrite_rule` for safety
- WordPress URL rewrite regex
- Custom rewrite rules are sending everything to index.php
- Getting add_rewrite_rule and add_rewrite_tag to work
- Prepend meta_value to permalink of post
- Blog installed in subdirectory but need to create pages in root. How to use permalinks?
- How to change ?lang=cn into /cn/
- WordPress Network on IIS7/SQL Server – Rewrite Issues
- Custom comments
- Rewrite rules goes away
- custom htaccess rewrite rule for page
- Rewrite Rule for Custom Page with Query Vars in URL
- WordPress keeps writing rewrite rules to .htaccess
- Adding the amp url prefix to the beginning
- WordPress Rewrite
- add_rewrite_rule again
- Dynamic URL, not a physical page within the database
- Rewrite Rule for Post “Subpage”, with pagination
- Need to make a php file inside theme accessible via url
- Tricky URL rewrite with custom values in url
- WP Rewrite the last two parts of the URL
- Why is there /index.php/ in all my links? How do I remove it?
- Rewrite loading custom template file but is_home() returns true, and there’s no 404
- Rewrite rule for admin-ajax.php
- Add rewrite rule to call front-page.php?
- Nginx rewrite rule conflict with WordPress permalinks rule
- Add a query string to ALL links on site
- How make a multi language routes, with rewrite rules or rewrite endpoints?
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- Add rewrite rule for rewrite endpoint
- Custom rewrite rule for backend/admin?
- Having trouble with using add_rewrite_rule and pagination
- Access $_POST data after redirect
- How to have multiple rewrite endpoints in the same URL?
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- Change Query String to pretty permalink
- add_rewrite_rule is not taking effect in WordPress? .htaccess file doesn’t update
- WordPress rewrite rules for state and city
- Adding more pages to author pages
- Using Blog Parent Slug on Blog Posts Only
- add_rewrite_rule not working for language specific characters
- How to add a custom redirect rule for subdomains?
- Custom rewrite rule
- Regionalised Content
- Single Redirection Rule for Pages and Archive links
- How to do Basic URL Rewrite Without Redirecting
- Is it possible to remove feeds from rewrites?
- Load a template page based on part of slug in wordpress
- Add specific word to default page permalink
- URL Rewrite doesn’t work for nested pages
- Flush Rewrite Rules on init or rest_api_init?
- Plugin action rewrite rule – non_wp_rules
- Remove “/page/1” from the URL
- Removing “category” from URLs then “add_endpoint()” won’t work…
- hard flush_rewrite_rules() not regenerating .htaccess
- Map alt domain to specific section of website w/o MU
- Rewrite URL – insert custom variables as a directory path
- Rewriting URLs in WordPress
- add_rewrite_rule() to route to file other than index.php