custom post types - Adding second comments.php for reviews

admin2025-06-05  3

I've just started a business directory website. I'm using a custom post type for this. I'd like to extend the site's purpose by allowing visitors to add reviews on each business.

I therefore wondered if I could create another comments.php file for the purpose of visitors leaving reviews on single business pages while leaving the original comments.php for blog comments. Of course, I've tried a few review plug-ins without success!

I've just started a business directory website. I'm using a custom post type for this. I'd like to extend the site's purpose by allowing visitors to add reviews on each business.

I therefore wondered if I could create another comments.php file for the purpose of visitors leaving reviews on single business pages while leaving the original comments.php for blog comments. Of course, I've tried a few review plug-ins without success!

Share Improve this question edited Jun 10, 2016 at 13:56 ajguitars asked Jun 10, 2016 at 12:45 ajguitarsajguitars 132 bronze badges 2
  • 3 While I want to leave your question open, I also want to ask you to read How to Ask, file an edit to your question and rephrase it. Verbosity helps both ends and showing at least your research, efforts and fails helps avoiding routes that you already have tried. Keep in mind that "I used plugin X" is not trying to solve this as this site is about developement, not installing plugins. Thanks. – kaiser Commented Jun 10, 2016 at 13:40
  • I have updated my question. I hope that make it's easier to understand - I do apologize for any confusion or lack of detail. – ajguitars Commented Jun 10, 2016 at 13:58
Add a comment  | 

1 Answer 1

Reset to default 0

I don't know what your comments.php looks like, so I cannot tell how to adapt your current code, but I can generally tell you how to approach this.

Normally, WP will assume that you want the latest comments of the current post. If you want something else, you start with the condition under which you want your second set of comments to show and add this to comments.php: if (my_condition) { show second comments set; }

Now, you have to tell WP which set of comments to use. You need to set $args which are available in the get_comments function. There are too many options to describe here.

Once you have retrieved comments with $comments=get_comments($args); you can feed them into the display function wp_list_comments($args,$comments). The $args to this function determine how the comments are displayed. You can have them shown completely different from you other comments set.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749071175a316106.html

最新回复(0)