
Have you been to a blog that have hundreds of comments which are separated into many pages? Now made easy with the Paged Comments feature from WordPress v2.7 onwards. It can be a pain sifting through each page looking for something. Now wouldn’t it be nice if there’s an option to show all comments with a click? Do your visitors a favor by adding a “Show All Comments” feature.
Since codes differ from theme to theme, I will be using my Google Chrome theme as an example. It should be fairly easy to apply to other themes.
Open comments.php and replace
<h3 id="comments">Reader's Comments</h3>
With
<h3 id="comments">Reader's Comments</h3>
<?php if ($_GET['showall'] != '1') { ?>
<a href="?showall=1#comments">Show all comments</a>
<?php } ?>
Replace
<?php wp_list_comments(array('callback' => 'custom_comment', 'type' => 'comment')); ?>
With
<?php if ($_GET['showall'] == '1') { ?>
<?php wp_list_comments(array('callback' => 'custom_comment', 'type' => 'comment', 'per_page' => '0', 'page' => '0')); ?>
<?php } else { ?>
<?php wp_list_comments(array('callback' => 'custom_comment', 'type' => 'comment')); ?>
<?php } ?>
Replace
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link('Newer Comments »') ?></div>
With
<?php if ($_GET['showall'] != '1') { ?>
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link('Newer Comments »') ?></div>
<?php } ?>
Browse and Share
» Subscribe to Feed» Leave a Comment
Related Posts:
» Theme Update: OneNews 3.1
» WP Plugin: Genki YouTube Comments
» WP Plugin Update: Genki Youtube Comments 1.1
» Newer Post: WP Theme: TheNews Magazine
« Previous Post: WP Theme: Edmin Blog












Great tip! I spent a lot of time thinking about a solution for that and turns out it’s simple and easy to implement.
I actually used a simple check in the beginning of the file:
$show_all_comments = isset($_GET['showall']);
This way you only need to href to “?showall”.
Thanks a lot for sharing!