Support » Plugins and Hacks » Hacks » Rewrite taxonomy slug in archive permalink

  • Resolved Ann-Sophie

    (@ann-sophie)


    I can access my custom taxonomies with this url: www.example.com/taxonomy-name/term

    But I’d like to have this rewritten to www.example.com/term

    Can anyone help me out with that? I have no idea where to start.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator bcworkz

    (@bcworkz)

    This is more difficult than it seems. The query parser needs some way to know the parameter belongs to the taxonomy and is not a post slug, date, author or other value it may need to query for.

    If there are not too many terms, your rewrite rule could effectively say “if the parameter is equal to one of the values on a short list, it is part of X taxonomy, otherwise process normally”

    If there are a lot of terms, there needs to be some common element to distinguish this taxonomy query from any other type of query.

    Did you try

    RewriteRule ^term/(.*) /taxonomy/term/$1 [L,R=301]

    That works like a charm!
    Perfect! Thanks a lot!

    Hi icd10,

    I think I cheered too soon… The archive pages still have the custom taxonomy name before the term.
    If I click a post the taxonomy name is gone though. Any ideas?

    The plugin to remove the taxonomy name added this to .htaccess:

    RewriteRule ^wp-types-group/(.+)/$ /$1 [R=301,L]
    RewriteRule ^{taxonomy-name}/(.+)/$ /$1 [R=301,L]

    Doesn’t seem to work either.

    Any ideas? Any help is appreciated!

    This turned out to be a plugin bug (WPML) I got great support there!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Rewrite taxonomy slug in archive permalink’ is closed to new replies.