Skip Navigation

[Resolved] Taxonomy Shows "Other" in URL

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.

This topic contains 6 replies, has 2 voices.

Last updated by Chris 8 years, 7 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#18100

I changed my taxonomy slug from singular to plural ("State" to "States") and now when i assign a taxonomy it just says other in the url

My url looks like this at the moment: Domain.com/location/other/test-page/ ‎

and used to look like this: Domain.com/location/CALIFORNIA/test-page/ ‎

I have deleted the custom post and tried to reassign a taxonomy to the new one but nothing works.

#18136

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Chris,

Could you describe the detail steps you take, I need duplicate the same problems in my localhost.

Thanks
Luo

#18177

1) Made a custom post type with "location" as the slug
-- Used a custom URL format: location/%state%
2) Made a taxonomy group with "state" as the slug
3) Made a page with the slug "state" to display the archive list

At this point everything worked perfectly.

1) Then I changed the taxonomy slug from "state" to "states"
2) And changed the page slug from "state" to "states"

After that, ive had issues.

#18178

This was automatically added to my htaccess file. Should I keep this there?

# BEGIN REMOVE SLUG CUSTOM POST TYPE RULES
RewriteRule ^wp-types-group/(.+)/$ /$1 [R=301,L]
RewriteRule ^/(.+)/$ /$1 [R=301,L]
RewriteRule ^un_feedback/(.+)/$ /$1 [R=301,L]
RewriteRule ^/(.+)/$ /$1 [R=301,L]
RewriteRule ^/(.+)/$ /$1 [R=301,L]
RewriteRule ^/(.+)/$ /$1 [R=301,L]
# END REMOVE SLUG CUSTOM POST TYPE RULES
#18251

I made a change again. Since Im chaging the slug from singular to plural, I noticed i didnt change this yet.

1) Made a custom post type with "location" as the slug
– Used a custom URL format: location/%state% <--------- Singular! (now changed to plural)

PROBLEM NOW: The slug in the URL no longer says OTHER, it now looks like this ( Domain.com/location/%states%/test )

Almost like it doesnt recognize it.

Any ideas? This is killing me! Thanks for the help in advance. 🙂

#18270

Ive tried a few more things and cant figure it out. So weird :/

#19058

I know nothing about PHP or function files etc… I think your plugin automatically add code to my functions file when I made a custom taxonomy, is that right? My issue again was when i changed my slug from singular to plural everything broke.

I FOUND THIS

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

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

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

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

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

I changed all the singular slugs to plural and everything works perfectly. I feel like i figured it out on my own after weeks and nobody at Types could.

Not exactly fair. I get better support from most free plugins.

Nothing I can do now, just pointing it out.