admin管理员组文章数量:1130349
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
1 Answer
Reset to default 0I 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.
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
1 Answer
Reset to default 0I 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.
本文标签: custom post typesAdding second commentsphp for reviews
版权声明:本文标题:custom post types - Adding second comments.php for reviews 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749071151a2311595.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论