Skip Navigation

[Resolved] Custom Taxonomies Permalinks

This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by sianE 2 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2412073

Tell us what you are trying to do?

I am trying to make my event custom post type permalink include the event-type taxonomy

Is there any documentation that you are following?

https://toolset.com/forums/topic/custom-taxonomies-not-showing-on-permalink/#post-16949

Here is the code I saved in the toolset code snippets, using the above documentation as a guide:

// custom taxonomy permalinks
add_filter('post_link', 'eventtype_permalink', 10, 3);
add_filter('post_type_link', 'eventtype_permalink', 10, 3);

function eventtype_permalink($permalink, $post_id, $leavename) {
if (strpos($permalink, '%eventtype%') === FALSE) return $permalink;

// Get post
$post = get_post($post_id);
if (!$post) return $permalink;

// Get taxonomy terms
$terms = wp_get_object_terms($post->ID, 'event-type');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
else $taxonomy_slug = 'other';

return str_replace('%eventtype%', $taxonomy_slug, $permalink);
}

The link shows correctly in the post editor (hidden link), but when you view the page, it says the page does not exist. I have managed to do this once before, following these instructions, but I lost that website and cannot work it out again!!

#2412091

Hello,

There isn't such kind of built-in feature within Toolset plugins, or even in WordPress core.

The custom codes you mentioned above is provided by another client, which is not in the range of Toolset support. See our support policy:
https://toolset.com/toolset-support-policy/
We cannot produce custom code solutions for you. When you need custom coding which extends Toolset functionality, we recommend contacting one of Toolset certified consultants.

And in my opinion, since each post can have multiple terms, it is not recommended to use such kind of post type permalink as you mentioned above, it will conducts other unexpected results.

#2412093

Hi there,

I am using this: https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

It has worked for me before, I just can't remember how I got it to work.

#2412095

Also, toolset support has helped before here: https://toolset.com/forums/topic/adding-taxonomy-slug-to-cpt-permalink/

This is only one example.

#2412131

I suggest you put those custom codes into your theme file "functions.php", in some cases, Toolset custom codes snippet does not work for some action/filter hooks, since those action/filter hooks are triggered before Toolset custom codes snippet.

For the custom codes issue, you can check it with Toolset Contractors:
https://toolset.com/contractors/

#2412137

I got it to work. For further reference for anyone else who has this problem, if you remove any "-" from taxonomy slugs, so only use letters, it works perfectly.