[resolved] Rewrite taxonomy slug in archive permalink (8 posts)

  1. Ann-Sophie
    Posted 2 years ago #

    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.

  2. bcworkz
    Posted 2 years ago #

    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.

  3. icd10
    Posted 2 years ago #

    Did you try

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

  4. Ann-Sophie
    Posted 2 years ago #

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

  5. Ann-Sophie
    Posted 2 years ago #

    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?

  6. Ann-Sophie
    Posted 2 years ago #

    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.

  7. Ann-Sophie
    Posted 2 years ago #

    Any ideas? Any help is appreciated!

  8. Ann-Sophie
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.