• 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

Remove Comments Specific Pages: Which Method is Better?

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 › Remove Comments Specific Pages: Which Method is Better?

This topic is: not resolved
  • This topic has 3 replies, 3 voices, and was last updated 12 years, 5 months ago by ericoahu.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • June 22, 2013 at 11:06 am #47186
    pxforti
    Participant

    I use the code below to add comments to a specific page. It works, but I'm not sure it's the best way to do it.
    Note: Neither examples works unless I turn on comments for pages in the Genesis theme settings first. Also, the genesis_after_entry is genesis 2.0; use genesis_after_post for genesis 1.x

    There are two code examples below and both work. Can anyone tell me if one way is more efficient than the other. Or if there is a better way to do it?

    Specifically: in first method, should I use genesis_before instead of wp_enqueue_scripts</strong. Also, is it better to use two if statements instead of one if statement with &&?

    First Method:

    add_action( genesis_before', 'wnd_remove_comments' );
    
    function wnd_remove_comments() {
    	if (!is_page(2358))	{
    		if ( is_page())	{
    			remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
    		}
    	}
    }

    Second Method:

    add_action( 'wp_enqueue_scripts', 'wnd_remove_comments' );
    
    function wnd_remove_comments() {
    	if ( is_page() && (!is_page(2358)))	{
    		remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
    	}
    }

    writeNowDesign
    WordPress and Ecommerce Website Design

    June 22, 2013 at 5:44 pm #47230
    rfmeier
    Member

    Hello,

    I am curious. Why do you want to use these methods instead of turning comments on and off within the page editor? I am wondering if I a missing something here.


    Ryan Meier – Twitter

    June 23, 2013 at 8:51 am #47289
    pxforti
    Participant

    I have too many pages that are already built and don't want to have to turn off comments every time I build a page.


    writeNowDesign
    WordPress and Ecommerce Website Design

    June 23, 2013 at 11:24 am #47296
    ericoahu
    Member

    If I remember correctly there is a WordPress setting to default to no comments, and then on any individual page where you want comments you check the box. In the future you wouldn't have to turn off comments every time you add a page.

    Or you could just remove the comments part from a custom page.php.


    Eric Lauritzen

    Google+·app.net

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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

© 2025 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