First question is if you flushed your permalinks after creating. If not, try that first. If you’re still having issues afterwards, let me know and I can think it through some more for any ideas.
Thread Starter
Xavvi
(@skinny-latte)
Yes I tried that. No luck unfortunately
Is this custom rewrite slug being set on the permalinks page? or the CPTUI settings for that taxonomy?
I’m curious if this permalink structure is going to take some custom snippets of code to help with parsing as well. We don’t offer every single part of the process in our plugin for the variety of permalinks that people want, we just provide the fields needed for at the point of registration.
Thread Starter
Xavvi
(@skinny-latte)
The rewrite slug is being set in the CPTUI settings for the taxonomy.
I’ve managed to get it working but only by setting up the custom post type manually in my functions file and using the following string replace function:
add_filter('post_link', 'information_permalink', 10, 3);
add_filter('post_type_link', 'information_permalink', 10, 3);
function information_permalink($permalink, $post_id, $leavename) {
if (strpos($permalink, '%info_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, 'info_category');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
else $taxonomy_slug = 'info_category';
return str_replace('%info_category%', $taxonomy_slug, $permalink);
}
I tried using just the string replace with the post type set up using the plugin but it didn’t work, presumably because the functions file is being called before the plugin or something?
Cool. Yeah, those filters you used aren’t something we provide any sort of UI for, so going that route is the best idea. I am curious why it didn’t work when having our plugin do the registration though.