• Resolved Martina Maurer

    (@la-stria)


    Hey!

    This might be an easy thing, but I don’t seem to get it myself.

    I try to code the $taxonomy->slug into a selfmade plugin. But for some reason it’s taking the default slug it had, before I started using this plugin. In the navigation, where the taxonomy is as well, the slug is correct. So it must be possible 😀

    So far I tried the basics

    • $taxonomy->slug returns the old slug
    • qts_get_slug($taxonomy->term_id, ‘de’) returns nothing

    Do I have to delete all categories and redo them with the new multilingual slugs?

    Cheers

    https://wordpress.org/plugins/qtranslate-slug/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Martina Maurer

    (@la-stria)

    Update:
    I deleted one of the categories (it’s a custom taxonomy btw) and redid it.

    Name de : 5 Endverankerung
    Slug de : Endverankerung

    Name fr : 5 Armatures d’ancrage
    Slug fr : Armatures d’ancrage

    Result from $taxonomy->slug in both languages: 5-endverankerung

    In the navigation the correct slugs are used.

    So, what can I do? 🙂

    Thread Starter Martina Maurer

    (@la-stria)

    Alright, I see the problem:

    When using qts_get_slug() the plugin code uses the WP-function get_post_meta() in class-qtranslate-slug.php line 629 while for taxonomies I would need get_term_meta().

    For anyone with the same issue, to get this working do something like this:

    // get the current active language
      $lang = qtrans_getLanguage();
    
      $args = array(
          'taxonomy'                 => 'your-taxonomy-name'
      );
      $taxonomies = get_categories($args);
    
      foreach ($taxonomies as $taxonomy) {
    
        $category_name = $taxonomy->name;
        $category_slug = get_term_meta($taxonomy->term_id, '_qts_slug_'.$lang);
    
        // do something with your variables here!
      }

    Hi Martina, glad you found the solution and shared it with everyone else!

    Good job, and thanks for using our plugin!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to display taxonomy slugs?’ is closed to new replies.