WordPress: How to Auto Expand Comments by Default

Just a little gripe I have with some of the WordPress themes created by some of those amazing designers out there. Some theme designers forget to provide the option to have the comment dialogue box auto expand at the end of articles. Not a problem when there’s a button stating “add comment here” but it is a problem when there isn’t such a button or when busy visitors are too much in a rush to look for such a button. Think about it, do you look for a comment box or do you look for a “add comment” button?

After a little bit of searching I found the code edits needed to make the comment box always visible for WordPress articles; and I must say thank you to Sheila Hoff for posting the solution in the WordPress support forum (I’ve linked to your homepage in gratitude).

Here’s what you need to do to automatically expand WordPress comments:

  1. Go to your Dashboard, find where it says “Appearance” in the sidebar on the left-hand-side then select “Editor”
  2. On the right-hand-side of the newly opened page, you will see a list of files; select the one that says “Main Index Template” or “index.php”
  3. Look for a line of text that reads
    <?php get_header(); ?>

    and add

    <?php $withcomments = 1 ?>

    onto a new line below it

  4. Now check through the page for any line of text that might say
    <?php comments_template(); ?>

    If it isn’t present then find

    <?php endwhile; else: ?>

    and above it, on a line of its own, add

    <?php comments_template(); ?>

The top of the edited code should now look similar to:

<?php get_header(); ?>
<?php $withcomments = 1 ?>

And somewhere toward the bottom it will then look like

<?php comments_template(); ?>
<?php endwhile; else: ?>

You will find it easier to search “index.php” if you copy it into a text editor, press ctrl+f then type your search terms.

Sharing is caring!

Leave a Reply

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

newest oldest most voted
Notify of

Nice brief and this enter helped me alot in my college assignement. Gratefulness you for your information.

I’m looking for how to autoexpend my comments. Now, your blog really help what I want. Thanks. Great content.

Should this work with wordpress 3.0?
Thank you

It doesn’t work with 3.0. Do you have any suggestions?

Very nice post thanks for sharing, just what I was looking for. Made the changes and was up and running in minutes.

Hi, I’ve applied your tip to WP 3.0.1 with the default twentyten theme. It’s index.php has no at the bottom anymore, but it ‘kind of works’ when you add the below get_header and put between the get_sidebar and get_footer. The only ting is that now it seems to randomly (I just don’t see the pattern yet), show a “Leave A Reply” field under some posts and not others. All posts with comments get the reply field, but also some others without comments. It takes too much space on the page, so it ‘kind of works’. Thanks for your tip! I’m… Read more »

some code got filtered out of my post:
no php endwhile at the bottom.
when you add the withcomments=1 below get_header and leave away the comments_template part near the bottom, I get the best results.

It’s still not an ideal solution:
-The comments indent not enough, which makes them look too much like a post, instead of comment.
-Huge empty “Leave a Reply” fields. While some is desired to encourage discussion, this is ott.

If you have any ideas, please let us know.

Works. In my case the there is no “else” piece.
Instead of I got . I searched for “endwhile” and found it. Thanks a lot.

My PHP code disappeared so I’ll try to use the CODE tag. Instead of I got in my php script.



Nice one :) Seems silly for this not to be default. Now my hoards of non traffic will be able to see the comments box!

I looked all over for this, thank you so much for posting it, really appreciate it


Thank you and Sheila!

KC de Cali

not working with cordobo green theame

Thanks for the update.

Thanks for the codes, it works to my site. Steps are easy to follow and understand. Well-done.

You’re welcome :)

Do it works to any version of wordpress?

It does. The only caveat is that some themes are badly coded and the modifications fail to work with such themes, otherwise it will work.

It regularly amazes me precisely how website owners for example your
self can find enough time and the commitment to carry on making terrific
blog posts.


I appreciate you taking the time to create this publish. It has been extremely helpful to me indeed. Appreciate it. http://www.mydietarystore.info

It’s challenging to find knowledgeable folks on this topic, but you sound like you know what you’re talking about! Thanks

Amanda Thomas

Many thanks for sharing these instructions! <3


what if neither line of text from step 4 is present? this is with iribbon pro


what if neither line of text is present from step 4? im using i ribbon pro


Great! very good explaination. I searched for this in all forums about wordpress, but all commend pointed to an other comment, which pointed to a other forum etc.

After an half hour google-ing I’ve found this and it’s exactly what i needed.

Thank you!

Thank you so much for this! It worked great! THANK YOU, THANK YOU for posting this!

Could you please repost what the code should now look like? I tried your solution and it “broke” my blog. Fortunately, I remembered what the code said before I edited it, and got it back. Thanks.

Fantastic !! thanks a lot! people were commenting in incorrect posts in my website because they didnt see the ´leave a reply´ for the post they wanted and were leaving the comment always in another posts

Please help! My dashboard doesn’t seem to have editor under appearance.

Never mind, it seems to have somehow sorted itself out.

Ok, the comments box appears and disappears. If you’re on my homepage, the the comments and the box are hidden. If you’re on a particular post’s page then they reappear. Is there a way I can keep the comments and the reply box permanently visible? Sorry for the multiple comments.


WordPress is a service that allows you to create a free website on their website. They have skins available for you to customize with easy drag and drop functionality. You are allowed to use a space they allow is currently quite popular because of its easy customization. Generally, it is very easy to install WordPress which is constantly updated http://www.instructables.com