0

Currently I have custom taxonomy terms from posts being posted to the front end with this code:

       $package_category = get_the_term_list( $post->ID, 'package-category', '', ', ' , '' );
            if(!empty($package_category)){
                echo '<div class="package-info">';
                echo '<span class="head">Categories: </span>';
                echo $package_category;
                echo '</div>';
        }   

The problem is they are returned the taxonomy terms in strange urls such as /package-category/category1/

Is it possible to remove the /package-category/ in the links so it just goes to /category1/ respectively?

  • 1
    They're not strange. They're based on whatever arguments you used when registering the taxonomy. The default behaviour is the taxonomy name. It can be changed, but not removed. Without it WordPress can't tell whether a URL is looking for a post with that name or one of your package categories. – Jacob Peattie Jul 17 '18 at 15:02
  • @JacobPeattie I see, I used the wrong wording, I guess it was strange for me as when I first did 'rewrite' => / when i registed taxonomy it worked, but thats only because i didnt refresh peralinks. Is there any way of redirecting to the corresponding /category1/ in the example? – JronCh Jul 17 '18 at 15:07
  • Try solutions suggested here. – Jacob Peattie Jul 17 '18 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.