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!

Subscribe
Notify of
guest

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

46 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
46
0
Would love your thoughts, please comment.x
()
x