WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 05 2012

How to Move the Comment Form Above the Comments List in Genesis

This is extremely easy and only involves only a few lines of code that can go into functions.php.

[php]
add_action( 'genesis_before_comments' , 'wps_post_type_check' );
function wps_post_type_check () {
if ( is_single() ) {
if ( have_comments() ) {
remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 5 );
}
}
}
[/php]

If you do not check for comments, then simply removing the form and adding it at the top of the list will remove the form altogether on single pages/posts that have no comments. We do this with a simple function, have_comments().

Written by Travis Smith · Categorized: Genesis

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Nate says

    June 16, 2012 at 10:36 am

    Thanks. This worked perfectly!

    Reply
  2. Johann says

    July 6, 2012 at 8:53 am

    This is useful. How can remove the ‘website’ option from the comment section? Can you help?

    Reply
    • Travis Smith says

      July 17, 2012 at 11:04 am

      Yes, here’s the tutorial: How to Remove the Website Field from Genesis Comments Form

      Reply
  3. Melissa B. says

    July 10, 2012 at 4:05 pm

    Perfect, worked beautifully. Thank you so much! 🙂

    Reply
  4. Lucy Jane says

    July 18, 2012 at 9:23 am

    Thank you! Works great!!!

    Reply
  5. Scottish Mum says

    September 5, 2012 at 7:30 pm

    Hi, how to remove the form without losing it when there are no comments on a post already. Moving the comments form worked for posts that already had comments, but for those that didn’t already have one, there was no form at all.

    Which part of the code should be removed for that. I’ve tried a couple of combos that didn;t work.

    Reply
  6. Angie says

    October 16, 2012 at 10:18 am

    Quick question on this, I love this code but on this site (post) here: http://demo.strosgirldesigns.com/cocoamommy/2012/07/21/hello-world/ is there a way to move the word COMMENTS to below the comment box?

    Reply
    • Travis Smith says

      November 2, 2012 at 1:39 am

      Yes there is. You will need to do this:
      [php]
      /** Remove Default Comments Heading */
      add_filter( ‘genesis_title_comments’, ‘_return_null’ );
      add_action( ‘genesis_after_comment_form’, ‘wps_comments_title’ );
      /**
      * Add Comments Heading
      */
      function wps_comments_title() {
      ‘<h3>’ . _e( ‘Comments’, ‘genesis’ ) . ‘</h3>’; // replace ‘genesis’ with your text domain, if you have one.
      }
      [/php]

      Reply
      • Joyann says

        November 6, 2012 at 5:52 am

        Travis, I get this error when I use your code to move Comments headline below comment box:

        Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘_return_null’ was given in /home/www/lacarriere.dk/wp-includes

        Wonder what needs to be changed?

        Reply
        • Travis Smith says

          November 12, 2012 at 5:28 pm

          It should be __return_null (with two underscores in the front).

          Reply
          • Alexandra says

            January 10, 2014 at 1:10 pm

            Thanks for this Travis. I had the exact same problem as Joyann. Now it works beautifully.

  7. Glen Craig says

    November 27, 2012 at 11:05 am

    Perfect instructions. Just what I was looking for, thanks!

    Reply
  8. Ari Herzog says

    August 3, 2013 at 9:44 am

    Hi Travis this is very helpful as I also wanted to switch the form from below the comments to above them.

    How can I remove the lines for “Comments” and “Leave a Comment” — so that the form is only for the name, email, website, and body?

    Reply
  9. Coralie says

    August 31, 2013 at 8:43 pm

    Worked PERFECT!!! Thank you!

    Reply
  10. Raquel @ My California Roots says

    May 22, 2014 at 5:00 pm

    I added this to the end of my funchtions.php and not I cannot access my site. What did I do and what do I need to do to fix it???

    Reply
  11. Leonard says

    May 30, 2014 at 2:31 pm

    Worked for me, too, but when I pasted your code into my functions file, it had smart-quotes. I had to replace them with straight quotes to get it to work.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in