Skip Navigation

[Resolved] Taxonomy in URL says OTHER (urgent)

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 8 replies, has 2 voices.

Last updated by Chris 8 years, 7 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#18361

I posted created a thread days ago and got a response but nothing since. I dont EVER repost a topic but Ive noticed onces my thread hits the third page I stop receiving help. This is the only thing i could think of doing to get noticed. My site is 110% out of commission. The taxonomies say other no matter what. Killing my seo and redirects.

Im not mad or blaming anyone. Just dying to figure this out 🙂

ORIGINAL THREAD: https://toolset.com/forums/topic/taxonomy-shows-other-in-url/

Also another reason i created this duplicate is because I cant find where i can see a list of all my started threads, I just keep looking through all the support pages and randomly find it. Sometimes i cant find them because they get so deep (page 30 etc).

#18383

Luo Yang
Supporter

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

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

Dear Chris,

In the ORIGINAL THREAD: https://toolset.com/forums/topic/taxonomy-shows-other-in-url/,

I followed your steps, but can not duplicate same problem in my localhost, could you send me the database dump to my email: luo.y@onthegosystems.com

Regards
Luo

#18440

I sent you the dump. Any ideas? 🙁

#18459

Luo Yang
Supporter

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

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

Hi Chris,

Please add follow codes in your theme/functions.php

add_filter('post_type_link', 'my_permalink_structure', 10, 4);
function my_permalink_structure($post_link, $post, $leavename, $sample) {
if ( false !== strpos( $post_link, '%states%' ) ) {
$term = get_the_terms( $post->ID, 'states' );
$post_link = str_replace( '%states%', array_pop($term)->slug, $post_link );
}
return $post_link;
}

Thanks for your patient.

Regards
Luo

#18763

Luo Yang
Supporter

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

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

According to the email, I have added you in the skype, thanks

#18783

Luo Yang
Supporter

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

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

reference for others, the fixed code:

add_filter('post_type_link', 'my_permalink_structure', 10, 4);
function my_permalink_structure($post_link, $post, $leavename, $sample)
{
if ( false !== strpos( $post_link, '%states%' ) )
{
$term = get_the_terms( $post->ID, 'states' );
if($term)
{
$res = str_replace( '%states%', array_pop($term)->slug, $post_link );
}
}
return $res;
}

#18789

Thank you so much!

#18999

NOT RESOLVED.. please help!! EMAIL ME: HondaCRF450R at gmail dot com

#19000

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.