• Is it possible to make this:

    <li><a href="categories-url">categories name</a> (25)</li>

    into this:
    <li><a href="categories-url">categories name (25)</a></li>

Viewing 2 replies - 1 through 2 (of 2 total)
  • You could try something like this:

    <ul>
    <?php
    $args=array(
      'orderby' => 'name',
      'order' => 'ASC'
      );
    $categories=get_categories($args);
      foreach($categories as $category) {
        echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name. ' ('. $category->count . ')</a> </li> ';
    }
    ?>
    </ul>
    Thread Starter Mercer2789

    (@mercer2789)

    Works beautifully, thank you for the code. Any Idea how to list them in this format with parent category hierarchy? I’m assuming whatever I need to add to this for parent/child will be somewhere in the docs.

    Again, thank you, your help was very much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Listing categories with the post count included inside the link.’ is closed to new replies.