Hi.
I have a custom post type "business-listing". At the moment the permalink structure is site_url/business-listing/post_title.
I have two custom taxonomy "business-category". I need to include this in the permalink structure and breadcrumbs. So my permalink should read: site_url/business-listing/business-category/post_title.
I found this in the support forum and have tried to follow it but it is not working. hidden link
Here is the code that I have changed it to following the tutorial:
//add custom taxonomy to url
add_filter('post_link', 'rating_permalink', 10, 3);
add_filter('post_type_link', 'rating_permalink', 10, 3);
function rating_permalink($permalink, $post_id, $leavename) {
if (strpos($permalink, '%business-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, 'business-category');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
else $taxonomy_slug = '';
return str_replace('%business-category%', $taxonomy_slug, $permalink);
}
Are there specific setting I need to have in my custom post type or custom taxonomy settings where I created it with Toolset? Do I need to have a specific permalink setting under the general setting of WordPress?
Howdy!
This feature isn't something that Toolset has been designed to accomplish. It's been a long time requested, tried and failed feature to add, going back to the beginning of Toolset's introduction.
The closest solution that has been devised over the years is at:
https://toolset.com/forums/topic/adding-custom-taxonomy-to-url-and-permalink-not-working/#post-16948
As you can see by going through Google to search our forums:
hidden link
I'm not saying it's impossible, but I am saying that permalinks and URL structure is too complex for us to include in the scope of support on the Forums as we have decided not to support it officially (at least appending the categories to the CPT slug).
It's interesting, this was my same exact question when I first bought Toolset. I created a Game Mods website, my CPT was "Games" and I wanted the taxonomy to be appended to it:
example.com/games/arma-3
I spent a solid week on it myself and I'm no stranger to htaccess or rewrite code and in the end, I got it working (sort of, adding child taxonomy terms broke it) but it kept breaking and made me want to throw my laptop across the room! In the end I decided on learning NodeJS and building a prototype in MeteorJS but that's besides the point, anyway.
I'm sorry I don't have the immediate solution but steadfast, the links above may help devise a custom solution or you could ask someone else to take on the migraines: https://toolset.com/consultant/