WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm using wp_list_categories like so:

            //list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)

            $taxonomy     = 'news_cat';
            $orderby      = 'name'; 
            $show_count   = 0;      // 1 for yes, 0 for no
            $pad_counts   = 0;      // 1 for yes, 0 for no
            $hierarchical = 1;      // 1 for yes, 0 for no
            $title        = '';

            $args = array(
              'taxonomy'     => $taxonomy,
              'orderby'      => $orderby,
              'show_count'   => $show_count,
              'pad_counts'   => $pad_counts,
              'hierarchical' => $hierarchical,
              'title_li'     => $title

            <ul class="categories fl">
            <?php wp_list_categories( $args ); ?>

which works great. it outputs as follows:

   <ul class="categories fl">
  <li class="cat-item cat-item-5">
    <a href="http://hhh.wp/news_cat/cat-1" title="View all posts filed under cat 1">cat 1</a>
  <li class="cat-item cat-item-6">
    <a href="http://hhh.wp/news_cat/cat-2" title="View all posts filed under cat 2">cat 2</a>
  <li class="cat-item cat-item-7">
    <a href="http://hhh.wp/news_cat/cat-3" title="View all posts filed under cat 3">cat 3</a>
  <li class="cat-item cat-item-8">
    <a href="http://hhh.wp/news_cat/cat-4" title="View all posts filed under cat 4">cat 4</a>

problem is i don't want an absolute path, just a relative one...

i need the href to read as /news_cat/cat-1

thanks in advance.

share|improve this question
up vote 3 down vote accepted

Hi @matt ryan:

Simplest way to do what you want is to use PHP output buffering. I haven't tested it yet but this should work:

wp_list_categories( $args );
$html = ob_get_clean();
echo str_replace(get_bloginfo('wpurl'),'',$html);


You could also using the 'wp_list_categories' hook like this:

function mysite_wp_list_categories( $output ) {
  return str_replace( get_bloginfo('wpurl'),'', $output );
share|improve this answer
right on. was looking for an official wp technique, but glad your flexing in php. – matt ryan Jan 29 '11 at 2:26
@matt ryan - Added an update for an alternate approach. – MikeSchinkel Jan 29 '11 at 4:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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