• Xblue02

    (@xblue02)


    Hi, I’m starting a new project and part of my idea requires me to create a page to list all of my categories and show how many posts are in each category. I have done some research with limited success, what I am using now is:

    <?php wp_list_categories(‘orderby=name&show_count=1’); ?>

    I have this wrapped in an unordered list tag

    Unfortunately it does not display anything.

    Here is a link to the webpage https://www.meanjoke.com/

    Any help will be greatly appreciated.

Viewing 1 replies (of 1 total)
  • Demetrius Pop

    (@demetrius-pop)

    Nice looking site.

    Drop this between your ul tags:

    <?php
    $args=array(
      'orderby' => 'name',
      'order' => 'ASC'
      );
    $categories=get_categories($args);
      foreach($categories as $category) {
        echo '<p>CATEGORY NAME OR WHAT EVER GOES HERE <br /> <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
        echo '<p> DESCRIPTION OR WHATEVER GOES HERE:'. $category->description . '</p>';
        echo '<p> NUMBER OF POST HEADING OR WHATEVER GOES HERE: '. $category->count . '</p>';  }
    ?>

    Please let me know how this works out.
    DemetriusPop ~

Viewing 1 replies (of 1 total)
  • The topic ‘Problem creating a page to display a list of categories with post counts’ is closed to new replies.