2

I simply want the link to be /catname instead of /category/catname for all the links listed using the wp_list_categories() function. Any ideas for this?

1 Answer 1

3

Okay, I've found the answer. This is not possible. So I had to build the permalink manually this way:

<ul class="list-items categories"> 
 <?php $category_ids = get_all_category_ids(); 
 $args = array( 'orderby' => 'slug', 'parent' => 0 ); 
 $categories = get_categories( $args ); 
 foreach ( $categories as $category ) { 
 echo '<li><a href="' . $category->slug . '" rel="bookmark">' . $category->name . '</a>  
 </li>'; } ?> 
</ul>
1
  • Great work. Thanks for posting this. I was having a similar issue and this solution helped me fix it. I didn't want the list of categories to be put under an <li> as wp_list_categories() does. Sometimes Wordpress has some stupid ways of doing things. Commented Sep 28, 2016 at 17:09

Your Answer

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

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