Wordpress Show All Comments

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 &raquo;') ?></div>

With

<?php if ($_GET['showall'] != '1') { ?>
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link('Newer Comments &raquo;') ?></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:
« Previous Post: