0

My Wordpress default category has 'news' category term. I created custom post type with name 'artist' and custom taxonomy named 'genre'. Now what I set in permalink section is below

custom structure - /news/%category%/%postname%/

because I want to open all my default post open with 'news' slug. I create page taxonomy-genre.php which lead to all post of genre taxonomy. let say genre taxonpmy has term 'afro-pop'. Now when I view the page it display all post of 'afro-pop' but problem is that it has url

http://localhost/mn2s-new/news/genre/afro-pop/

what I want is

http://localhost/mn2s-new/genre/afro-pop/

I want to remove that news slug for taxonomy-genre.php page. Please help me with this I am trying from 2 days but doesn't find any solution.

1 Answer 1

3

This is controlled by the with_front argument in your taxonomy registration code:

register_taxonomy(
    'genre',
    'artist',
    array(
        'rewrite' => array(
            'slug' => 'genre',
            'with_front' => false, // don't prepend static prefix from post permalink
        ),
        // your other args...
    )
);
1
  • thanks for the answer. I knew about it but I was trying complicated method like generate_rewrite rule. but u saved my day. thanks a lot. I don't have enough reputation to vote u up but when I will get enough reputation I will definitely do it. thanks thanks thanks Dec 13, 2018 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.