[Waiting for user feedback] Custom taxonomy permalinks

This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Our next available supporter will answer your ticket in about 2.48 hours from now. Thank you for your understanding.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Tagged: 

This topic contains 6 replies, has 2 voices, and was last updated by  Noman 4 days, 15 hours ago. The support staff assigned to this topic is Noman.

Viewing 7 posts - 1 through 7 (of 7 total)
Author
Posts
#576749

Please reopen my ticket

https://wp-types.com/forums/topic/custom-taxonomy-permalink/

which is now closed. Tried to post a new reply but I get an error. Thank you.

#576786

Noman
Forum moderator

Supporter languages: English (English )

Supporter Timezone: Asia/Karachi (GMT+05:00)

Hi Aris,

Thank you for contacting us. We can continue our discussion here. Please let me know what you require further in regards to original details provided earlier.

Thank you

#576802

Thank you. Sorry for not keeping the thread alive (I got all the warnings but I was away).

In response to your last message,
thank you for providing this resource. Indeed this is a step towards the right direction. But I still don't get the desired result.

(Of course in this link you suggested
https://wp-types.com/forums/topic/custom-taxonomies-not-showing-on-permalink/#post-16949
the solution applies also in the case where both custom taxonomies and custom post types are used. In my case I do not use custom post types, I stick to WC products).

I guess the only addition is the code part. All other settings are WP Types defaults (if I'm not mistaken).
The code successfully allowed us to use the custom taxonomy slug in WP's permalinks. So in my case I used

/shop/%watch-category%/

as custom base.

However the end result is (for a single product):

www.mysite.com/shop/watch-mens/boss-555555/

To clarify, the hierarchy is 'Watch -> Men'. The respective slugs are 'watch' and 'watch-mens'.

As you can see the custom code shows only the last child (the subcategory) and not the whole hierarchy. It should be something like

www.mysite.com/shop/watch/watch-mens/boss-555555/

I understand this is not in WP Types context but I still would appreciate your help as I am rather new to WP direct coding.

Thanks again

PS: The code I have used is this:

add_filter('post_link', 'watchcategory_permalink', 10, 3);
add_filter('post_type_link', 'watchcategory_permalink', 10, 3);
 
function watchcategory_permalink($permalink, $post_id, $leavename) {
        if (strpos($permalink, '%watch-category%') === FALSE) return $permalink;

        // Get post
        $post = get_post($post_id);
        if (!$post) return $permalink;
 
        // Get taxonomy terms
        $terms = wp_get_object_terms($post->ID, 'watch-category');
        if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
        else $taxonomy_slug = 'other';
 
        return str_replace('%watch-category%', $taxonomy_slug, $permalink);
}
#576893

Noman
Forum moderator

Supporter languages: English (English )

Supporter Timezone: Asia/Karachi (GMT+05:00)

Thanks for providing more details. Please provide temporary access (WP-Admin and FTP Login info) to your site (preferably staging site), so that I can look into your setup and check this further. Please note that we do not debug custom code or custom requirements much as per our support policy (https://wp-types.com/toolset-support-policy/) but I would like to take a look and see what I can find.

Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

✙ Please also provide links to your Taxonomy, Product, CPT that you would like to use, anything that's needed for this.

Thank you

#576945

Noman
Forum moderator

Supporter languages: English (English )

Supporter Timezone: Asia/Karachi (GMT+05:00)

Hello Aris,

I have done more testing on getting the required URL. Since we are using WooCommerce I find out that the solution given here won’t going to help much: https://wp-types.com/forums/topic/custom-taxonomies-not-showing-on-permalink/#post-16949

Here is why:
- Above solution will give us url like: http://www.example.com/Post-Type/Taxonomy/Post-Title
- Which means it will give us url like: http://www.example.com/product/Taxonomy/Post-Title
(which is we don’t need).

- We need url like this: http://www.example.com/shop/Taxonomy/Post-Title
So I managed to achieve this result with an alternate way, I tried various things and codes but only this is what possible as long as its for your current requirements and I think it's good, I have made a short video explaining what I have done here:
https://drive.google.com/file/d/0B5EmJQ1qcuyqUlJBSjBaTzEyV2s/view?usp=sharing

A related video I found:
https://www.youtube.com/watch?v=-YJ190Kne6A

Thanks

#578662

Dear Noman,
I reviewed your last post thoroughly. I don't follow though. I couldn't pinpoint any action besides the defaults. I am not famous for my observing capabilities...so please let me know what exactly differentiates the actions in your video from the defaults.
In any case I would appreciate if you could keep this thread open as due to personal issues I am not able to review and reply in a timely manner.

In any case I really appreciate your time and effort.
Thanks

#579028

Noman
Forum moderator

Supporter languages: English (English )

Supporter Timezone: Asia/Karachi (GMT+05:00)

Hello Aris,

In the video basically I have shown how to get the url as you need:
http://www.mysite.com/shop/watch/watch-mens/boss-555555/

And yes I have used built-in options, the main thing is creating a Custom taxonomy and setting up categories hierarchy. The custom code solutions we found previously are not useful in the end. So that’s all we can do to get the url structure you need.

Other than that if you are not comfortable with the solution I have used to get that url above, rest falls into pure Custom coding & custom development and it is out of support policy (https://wp-types.com/toolset-support-policy/). So we recommend to contact Toolset recommended service providers to further discuss the custom approach. We have some recommended list of service providers here if you would like to take a look: https://wp-types.com/consultant/

Thanks

Viewing 7 posts - 1 through 7 (of 7 total)

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.