• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Show number of posts from categories on category page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Show number of posts from categories on category page

This topic is: not resolved

Tagged: count posts, posts count

  • This topic has 4 replies, 2 voices, and was last updated 9 years, 11 months ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • November 11, 2016 at 5:36 pm #196048
    harshajayman
    Member

    I am making a song lyrics site. Every category is an artist. I want to show number of posts published per artist on the category page

    Currently category page is showing the loop with post titles. Ideally want to show the total number of song for each category before the start of the loop.

    I have genesis extender . So I can use a hook box if somebody can come up with a shortcode for this please

    Many thanks

    http:// www.sinhalasongbook.com
    November 11, 2016 at 7:44 pm #196049
    Brad Dalton
    Participant

    Here's the starting point using wp_count_posts


    Tutorials for StudioPress Themes.

    November 11, 2016 at 8:28 pm #196050
    Brad Dalton
    Participant

    You could also use wp_list_categories with the show_count parameter


    Tutorials for StudioPress Themes.

    November 12, 2016 at 2:47 pm #196070
    harshajayman
    Member

    Thanks a lot . You always help us out

    wp_list_categories with the show_count parameter wouldn't work because I need it to be shown on top of the category page

    Please see this category page for one artist for an example. I would like to show it say may be just after the banner or something

    http://www.sinhalasongbook.com/category/milton-perera/

    I tried adding a hook box genesis_before_loop and putting the php code

    <?php
    $count_posts = wp_count_posts();
    ?>

    But no luck
    Thanks

    November 12, 2016 at 9:15 pm #196079
    Brad Dalton
    Participant

    wp_list_categories is used in the categories widget to show number of posts for each category so it does work. You can look in the widget file to see how.

    You could also use the following functions:

    get_the_terms
    get_posts
    

    Please search for these relating to posts count for each category and you will find the answer


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble