Skip Navigation

[Resolved] How to create post URLs with a nested custom taxonomy

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 1 reply, has 2 voices.

Last updated by Mateus Getulio 1 year, 5 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2468925

As you can see here, I have a custom post type "Events" with a custom taxonomy, "Event Calendar".
I have one Event named "004964" and a custom taxonomy of "2022" as the parent, "October" as the child (slug is "10").

hidden link

hidden link

So what I would LIKE the URL to show as is:
mysite.com/events/2022/10/004964

I figure there must be a way to do this.

Currently it just shows as mysite.com/events/004964

Can you advise?

#2469509

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Welcome to the WPML support forum!

Unfortunately, WordPress becomes very user-unfriendly once you want to start manipulating the URLs in the way you describe. It is possible, but requires custom code, which we cannot provide.

You may find this article a helpful starting point: hidden link

The first part requires setting custom rewrite rules that include some placeholder text when the post type is first registered, and the second part uses the post_type_link filter to dynamically replace that placeholder text with your custom taxonomy term.

In terms of how you would do the same using Toolset, what you need to know is that the post type is registered by Types (according to what you enter in Toolset > Post types) and you cannot set the rewrite argument as described in the article.

What you can do, though, is use the WordPress filter register_post_type_args to modify the arguments used to register the custom post type as described in the article, by adding code such as this to your theme's functions.php file (not in Toolset > Settings > Custom Code):

	
function tssupp_custom_rewrite($args, $post_type) {
 
    $slug = 'project'; // Edit the slug of the post type
 
    if ($post_type == $slug) {
 
        $args['rewrite'] = array('slug' => $slug . '/%customtaxonomy%', 'with_front' => 1);
    }
 
    return $args;
}
add_filter('register_post_type_args', 'tssupp_custom_rewrite', 10, 2);

You would then be in a position to do something similar to what is described in the second part of the article. At this point, it would be necessary to configure it with some code customization. I'm afraid it is beyond the scope of this support forum (https://toolset.com/toolset-support-policy/) but we recommend that you check our contractors page: https://toolset.com/contractors/.

Please make sure to check these related topics that might be useful:

https://wordpress.org/support/topic/adding-directory-to-permalink-for-custom-taxonomy-posts/
https://wordpress.org/support/topic/permalink-for-parent-child-items-in-custom-taxonomy/
https://wordpress.org/support/topic/how-do-you-make-the-taxonomy-permalinks-hierarchical/

We’re looking forward to your reply. Thanks!

Kind regards,
Mateus.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.