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:
- Go to your Dashboard, find where it says “Appearance” in the sidebar on the left-hand-side then select “Editor”
- 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”
- In the editor window you will see text that starts with
<?php
followed by more text. Look for a line that says
<?php get_header(); ?>
and add
<?php $withcomments = 1 ?>
onto a new line below it
- 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(); ?>
So the top might then look like:
<?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.
Want to republish this content? Read the copyright notice first.. Like this, support this.









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.
Glad I helped :)
Thanks for posting
Should this work with wordpress 3.0?
Thank you
I haven’t tried it with WP 3. Let us know when you have, thanks :-)
It doesn’t work with 3.0. Do you have any suggestions?
I don’t at the moment. I’ll have a think and let you know if I come up with any.
Very nice post thanks for sharing, just what I was looking for. Made the changes and was up and running in minutes.
Thank you for visiting Matt. I’m happy it worked.
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 glad I’ll be able to shape it without another plugin.
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.
Hi Martinex. I’m actually looking at your site right now. I like it. Thank you for introducing me to it.
Re the comments box: does the same happen when you use a different theme? I’m not sure why the the “Leave a Reply” shows under some posts and not others. I would need to test the tip on one of my test sites to work it out. For the comment box’s size and position, I would edit the theme’s CSS and HTML/PHP to move and resize the comment box to your desired place.
Thank you for your feedback Martinex.
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 gotin my php script.John, thank you for your response. the code tag has been stripped out also. Better to just quote it instead.
gtgretertrg
Nice one :) Seems silly for this not to be default. Now my hoards of non traffic will be able to see the comments box!
Lol, glad it worked for you :)
I looked all over for this, thank you so much for posting it, really appreciate it
You’re welcome Mike. Thanks for visiting. Remember to backlink to JournalXtra so others can find this information more easily :)
Thank you and Sheila!
KC de Cali
not working with cordobo green theame
Thanks for the advice.
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
Many thanks for sharing these instructions! <3
You are welcome Amanda.
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
I’m not familiar with that theme. You need to ask the theme developer for his input.
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!
If only Google new where to find good content ;)
Thanks, Richard.
Thank you so much for this! It worked great! THANK YOU, THANK YOU for posting this!