0

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!

  • 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 Jun 10 '16 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 Jun 10 '16 at 13:58
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.

  • Thanks for you input. I'm using the standard comments.php. Can I start by copying it and rename it [to something like comments-review.php] ? – ajguitars Jun 10 '16 at 14:01
  • 1
    Yes, of course you can. If you have different templates for blog and review pages, you can simply call different comment templates from there. You can also edit the $args for comment_form if you want different input fields – cjbj Jun 10 '16 at 14:04
  • Great! I'll have a go and ask about customizing the $args later. Thanks again cjbj – ajguitars Jun 10 '16 at 14:22
  • I've had a play and got it working! So thanks for your help. My next two questions are can I remove the "reply" after each comment? and how should i go back adding rating stars? – ajguitars Jun 10 '16 at 20:05
  • @ajguitars The first question depends on your theme and the second on a plugin. While both would be follow up questions, they are not as third party software is off topic. – kaiser Jun 10 '16 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.