• Resolved 67thavenue

    (@67thavenue)


    What code can I use to display the number of posts in a given category, but not all categories.

    Thanks!

    -James

Viewing 7 replies - 1 through 7 (of 7 total)
  • <?php
    //display post count for category 63
    $categories=get_categories('include=63');
    if ($categories) {
    foreach($categories as $category) {
    echo 'post count is ' . $category->count;
    }
    }
    ?>
    Thread Starter 67thavenue

    (@67thavenue)

    thanks!

    so, i replace “63” with my category name?

    You would replace 63 with your category ID.

    Or change this:

    $categories=get_categories('include=63');

    to

    $categories=get_categories('include='.get_cat_ID('your category name here'));

    Thread Starter 67thavenue

    (@67thavenue)

    Perfect! It worked!!!! Thanks again!

    wildhalf

    (@wildhalf)

    Micheal

    This works for what i am trying to do but how could i modify it to get the count for each of my categories…

    MichaelH

    (@michaelh)

    Change this:
    $categories=get_categories('include=63');

    to

    $categories=get_categories();

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘number of posts in one category’ is closed to new replies.