I’m facing a challenge with the permalink structure on my WordPress site, and could use some guidance. My site hosts webinars led by different influencers, and I’m trying to organize these webinars into a clean URL structure based on the influencer’s name and the webinar topic.
Here’s the structure I’m aiming for:
* [https://www.sitename.com/webinar/influencer-name/blueprint](https://www.sitename.com/webinar/influencer-name/blueprint)
* [https://www.sitename.com/webinar/influencer-name/content](https://www.sitename.com/webinar/influencer-name/content)
* [https://www.sitename.com/webinar/influencer-name/analytics](https://www.sitename.com/webinar/influencer-name/analytics)
* [https://www.sitename.com/webinar/influencer-name/roadmap](https://www.sitename.com/webinar/influencer-name/roadmap)
I have created a custom post type of “webinar” and a custom taxonomy of “influencer”. I am using the “Custom Post Type Permalinks Plugin” to route the “webinar” post type like this: sitename.com/webinar/%influencer%/%postname%/
Each influencer conducts the same set of webinars so I use the influencer’s name as a unique identifier in the URL. However, WordPress automatically appends a -2, -3, etc., to the slug of the webinar when the same topic is used by another influencer, which I want to avoid.
For example, I have [www.sitename.com/webinar/BillyBob/blueprint](https://www.sitename.com/webinar/bill/blueprint)
But when I try to make [www.sitename.com/webinar/George/blueprint](https://www.sitenam.com/webinar/George/blueprint) \- it automatically appends “-2” to the end. The URL’s are different but WordPress is identifying the slugs as the same.
I then tried to create another custom taxonomy of “webinar\_topic” and change the permalink structure to [sitename.com/webinar/%influencer%/%webinar\_topic%/](https://sitename.com/webinar/%influencer%/%webinar_topic%/) but the individual posts in the “webinar” post type do not display correctly and it keeps loading the influencer archive page instead.
* Is there a way to set up WordPress so that it allows the same post name (blueprint, content, etc.) under different influencers without appending the incremental suffix?
* Can custom rewrite rules or another approach solve this issue, allowing for scalability as we add more influencers and topics?
I hope that was clear lol. Any advice or insights on how to configure this correctly would be greatly appreciated. Thank you!
[ad_2]
As far as I know, there’s no way unless you add some redirects. WordPress will check the post name for generating slugs, regardless of the category or other parameters. If there are posts with identical names, wordpress will add -2… to the end.
Yes, your question is clear, and it’s a common challenge when dealing with custom post types and taxonomies in WordPress. You’re on the right track with using custom rewrite rules to handle this scenario. Here’s a step-by-step approach to solve your issue:
1. **Custom Rewrite Rules:** You can define custom rewrite rules to handle the structure you desire. This involves using the `add_rewrite_rule()` function to create rules that map your desired URL structure to the appropriate query parameters.
2. **Custom Query Variables:** Since you’re using custom taxonomies (`influencer` and potentially `webinar_topic`), you’ll also need to ensure that WordPress recognizes these as query variables so it can correctly parse the URLs and fetch the appropriate content.
Here’s a basic example of how you can set this up:
phpCopy code
function custom_rewrite_rules() {
add_rewrite_rule(
‘^webinar/([^/]+)/([^/]+)/?$’,
‘index.php?post_type=webinar&influencer=$matches[1]&name=$matches[2]’,
‘top’
);
}
add_action(‘init’, ‘custom_rewrite_rules’);
function custom_query_vars($query_vars) {
$query_vars[] = ‘influencer’;
return $query_vars;
}
add_filter(‘query_vars’, ‘custom_query_vars’);