• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WriteNowDesign - Wordpress and Ecommerce Website Design

WordPress, Joomla, Ecommerce Website Design

  • Home
  • Prices/Packages
  • WordPress
  • Services
  • Portfolio
  • Blog
  • About
    • Testimonials
    • Locations
    • Online Payment
  • Contact
  • Show Search
Hide Search

Call 303-907-6133 Email

Genesis Add Comments to Specific Pages

How to Add Comments Form to Specific Pages in Genesis

June 22, 2013 by Pat Fortino

Method 2

  1. From the WordPress admin menu, select Genesis > Theme Settings.
  2. Scroll down to the Comments and Trackbacks section and click Enable comments on pages.Genesis Enable Comments on Pages
  3. The previous step turns on comments for all pages. Now we will turn comments off for all pages except for specific pages; in this case, the page with ID 58. Add the following code to your Genesis theme’s functions.php file.
    // Remove page comments except for specific pages
    add_action( 'genesis_before', 'wnd_remove_comments' );
    function wnd_remove_comments() {
    	if ( is_page() && (!is_page(58)))	{
    		remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
    	}
    }

     

    Note: The code above is for Genesis 2.0. If you are using a Genesis 1.x template, change genesis_after_entry to genesis_after_post

    Also Note: the code is for one page only: page ID = 58. If you want to add the comments form to several pages, replace (!is_page(58))) with (!is_page(array(42, 56, 85))) where the page IDs are 42, 56, and 85. To find the page ID, from WordPress admin menu, click Pages and then put your cursor over the page title link to view the ID. In the image below, the browser shows the post ID of 2002 when I put my cursor over page title.

    WordPress Find Post ID

  4. Test your pages. You should have comments form only on pages whose IDs you specified in the code. No other pages should have the comments form.
Pages: Page 1 Page 2

Tagged With: genesis, Comments are closed. If you have information to share, contact me here.

Previous Post: « 10 Empty Words and Phrases to Avoid in Your Blog
Next Post: Genesis 2.0 Change Featured Image Alignment »

Reader Interactions

Comments

  1. Mark says

    August 31, 2013 at 10:06 am

    Thanks for the insight on using the ‘genesis_after_entry’ hook, I was trying to use the ‘genesis_comments’ hook but that’s obviously executed to late.

    However you are using the wp_enqueue_scripts hook to remove the action, that hook should only be used to load scripts and stylesheets; you should use the ‘wp’ hook for these kind of functions, so your code would be:

    // Remove page comments except for specific pages
    add_action( ‘wp’, ‘wnd_remove_comments’ );

    function wnd_remove_comments() {
    if ( is_page() && (!is_page(58))) {
    remove_action( ‘genesis_after_entry’, ‘genesis_get_comments_template’ );
    }
    }

    • Pat Fortino says

      August 31, 2013 at 11:17 am

      Hi Mark,

      Thanks for the comment. You are correct the wp hook works. Also, I figured out that genesis_before works too.

  2. and says

    September 11, 2013 at 11:30 am

    You can also use a page template and a genesis_get_option filter, like this:


    <?php
    /*
    Template Name: Page With Comments
    */

    add_filter( 'genesis_pre_get_option_trackbacks_pages', 'custom_page_with_comments' );
    add_filter( 'genesis_pre_get_option_comments_pages', 'custom_page_with_comments' );

    function custom_page_with_comments() {
    return true;
    }

    genesis();

    • Pat Fortino says

      September 11, 2013 at 12:20 pm

      Thanks. I’ll give that a try. Looks like a more simple solution.

Related

Primary Sidebar

Blog Categories

Call Today

Get a Free Quote

303-907-6133

Subscribe to News

News about WordPress, WooCommerce, & Technology

What’s New

  • WPForms Not Sending Notifications
  • Add Terms and Conditions WooCommerce
  • Fix WordPress AMP Validation Errors
  • Use the Classic Editor with Gutenberg Block Editor
  • Add a Message at Top or Bottom of WooCommerce Checkout Page
  • How to Link to a PDF in WordPress

Find Us On…

  • Facebook
  • LinkedIn
  • RSS

Call 303-907-6133 Email

© 2004–2023 · WriteNowDesign · Sitemap · Log in · Return to Top

 

Loading Comments...