Make your comments look awesome on separate pages

You don’t have to install a completely new commenting system on your WordPress webpage in order to make your comments section different.

In one of our next articles, we will show you how to open comments in a popup window with a few WP tricks, but if you’re trying to get a slightly different solution, today we’re going to show you how to open those comments on a completely new page.

This trick will let you remove the standard comments template, create a link to a new page and then create that new page for each post so that every post can have its own comments page. If your site is heavy on comments and you rely on people’s opinion, this might create a much more dynamic environment where comments can act as discussion pages for a post that lead to it.

To make this trick work, you will be using WordPress’ popup comment script which is slightly modified in order to open a new page instead of a popup.

Now that you have decided to have comments on a separate page, let’s start customizing the system.

Remove the old commenting system:

First, you will need to remove the old comments template – If you’re opening comments on another page, you don’t want them to load the post content, right?

  1. Open single.php file
  2. Remove the line of code which loads the comments template. Don’t forget to save the code somewhere in order you make a mistake and want everything back:
  3. <?php comments_template('', true); ?>
  4. Save changes

Create a link:

Now you are ready to create a link which will lead to the comments page. So far, you don’t have a page, but don’t worry; the code will create one according to each post ID:

  1. Open single.php file again
  2. Find a place where you want the link to appear (if you want the usual, place the code right after the post content:
  3. <a href="http://www.yourwebsite.com/?comments_popup=<?php the_ID(); ?>"
    class="btn btn-primary">
    <?php comments_number('There are no comments', '1 Comment', '% Comments and counting'); ?></a>
  4. Change the URL on the first line
  5. for example: <a href=”http://www.firstsiteguide.com/?comments_popup=<?php the_ID(); ?>”

  6. Change text on the third line if you want to. Those three variables contain text which will be shown as link when there are no comments, when there’s only one or when there are several comments already posted.
  7. Save changes

Create a new PHP page for your comments in separate pages:

You are almost done. But before you can go on and test your new commenting system, you will still have to create a new PHP page which will actually contain comments for each and every post.

  1. Open your FTP client like FileZilla
  2. Go to /wp-includes/theme-compat/ where the file is usually located
  3. Create a new file and name it comments-popup.php
  4. Open source code on GitHub https://github.com/WordPress/WordPress/blob/master/wp-includes/theme-compat/comments-popup.php
  5. Copy and paste the code in the file
  6. Save changes

That’s it. Now you can test your new system, style it to your needs and add/remove content as you wish. If you have done everything correctly, your comments will now open on a new page while each post will have its own comments page with a different ID.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *