• 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

Conditionally include Comment Count Button in Blog page if there are any

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 › General Discussion › Conditionally include Comment Count Button in Blog page if there are any

This topic is: not resolved

Tagged: genesis_post_comments_shortcode, post_comments

  • This topic has 2 replies, 2 voices, and was last updated 7 years, 11 months ago by Brad Dalton.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • June 26, 2018 at 11:19 am #221140
    MikeKirkland
    Member

    I want to show the Comment Count Button on the Blog Page only if there are comments. Right now it's showing "Leave a Comment" if there are no comments for the post/snippet. That's silly because the post has not been read. For posts with comments, the button shows the number of comments - which is also a bit silly because there is a link to the Reply area at the bottom of the Post.

    First things first - conditionally showing the button.

    I've tried using the following code in page_blog.php in the child theme (which was already modified to allow a custom image for the header), copied from comments.php just changing add_filter to remove_filter.

    if ( 0 == get_comments_number() ) { 
        remove_filter('get_comments_link', 'genesis_comments_link_filter', 10, 2 );
    }

    This has no effect.
    Thanks
    Mike

    http://site is currently only on a LAN
    June 30, 2018 at 1:37 am #221235
    Brad Dalton
    Participant

    What you need to do is modify the following function located inside genesis > lib > shortcodes > post.php

    add_shortcode( 'post_comments', 'genesis_post_comments_shortcode' );
    

    using the genesis_post_comments_shortcode filter so it only displays when the comments number is 1 or greater


    Tutorials for StudioPress Themes.

    June 30, 2018 at 1:55 am #221236
    Brad Dalton
    Participant

    Any modifications would need to be completed inside your child theme folders functions file and never to the code in Genesis.

    You'll also need to add a conditional to the code so it only executes on the blog page.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ 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