admin管理员组文章数量:1130349
I have an issue in my new theme.
my website is about Education for teachers and students. every post belongs to one teacher that students can talk to her/him via comments.
now, i want to add a special thing to any post. i want to have two comments_template() in one post with pills (bootstrap). in one, student can just ask their questions but in another, they can do review and rating.
in fact i need to use different comments_template file for every one.
but the problem is: by adding two comments_template to one post, every comment will be displayed in another part too. but i want to just to be displayed in its part (pill).
so can you help me in this case???
i really need it. thanks y friends
UPDATE:
for example, i added these codes to the single.php to have 2 comment_template(). one for discussing and another for rating to the teacher. but when i comment in one part, it will be shown in another too. and i want to use different comment_tamplate() for avery part:
<div class="row container-fluid profile_nazar" style=" margin: 0 5% 30px 5% !important; margin-bottom: 20px; border: 1px solid #ddd; box-shadow: 0 0 6px #ccc;">
<ul class="nav-pills profile_pills">
<li><a data-toggle="pill" href="#pill1">Talk</a></li>
<li><a data-toggle="pill" href="#pill2">Rate</a></li>
</ul>
<div style="width:100%; height:400px; overflow-y: scroll;">
<div class="tab-content">
<div id="pill1" class="tab-pane fade in active" style="margin: 20px;">
<?php comments_template(); ?>
</div>
<div id="pill2" class="tab-pane fade" style="margin: 20px;">
<?php comments_template(); ?>
</div>
</div>
</div>
</div>
I have an issue in my new theme.
my website is about Education for teachers and students. every post belongs to one teacher that students can talk to her/him via comments.
now, i want to add a special thing to any post. i want to have two comments_template() in one post with pills (bootstrap). in one, student can just ask their questions but in another, they can do review and rating.
in fact i need to use different comments_template file for every one.
but the problem is: by adding two comments_template to one post, every comment will be displayed in another part too. but i want to just to be displayed in its part (pill).
so can you help me in this case???
i really need it. thanks y friends
UPDATE:
for example, i added these codes to the single.php to have 2 comment_template(). one for discussing and another for rating to the teacher. but when i comment in one part, it will be shown in another too. and i want to use different comment_tamplate() for avery part:
<div class="row container-fluid profile_nazar" style=" margin: 0 5% 30px 5% !important; margin-bottom: 20px; border: 1px solid #ddd; box-shadow: 0 0 6px #ccc;">
<ul class="nav-pills profile_pills">
<li><a data-toggle="pill" href="#pill1">Talk</a></li>
<li><a data-toggle="pill" href="#pill2">Rate</a></li>
</ul>
<div style="width:100%; height:400px; overflow-y: scroll;">
<div class="tab-content">
<div id="pill1" class="tab-pane fade in active" style="margin: 20px;">
<?php comments_template(); ?>
</div>
<div id="pill2" class="tab-pane fade" style="margin: 20px;">
<?php comments_template(); ?>
</div>
</div>
</div>
</div>
Share
Improve this question
edited Dec 10, 2018 at 12:04
sh.dehnavi
asked Dec 8, 2018 at 12:19
sh.dehnavish.dehnavi
411 silver badge12 bronze badges
14
|
Show 9 more comments
1 Answer
Reset to default 0i could not solve the main problem (two comments_template() in one post) but i created a new post_type for "talk to teacher" part and so we will create a post for every teacher in that post type and put the link of that post in teacher's profile page. by clicking on that link, students will go to new post that can just comment for the teacher and talk with her/him.
.
so by the following code, we can find that post in the new post_type to be used in the profile page:
consider: also in the new post, the author is the same.
<?php
$author_id = get_the_author_meta( 'ID' );
$post_ids = get_posts(array( 'fields' => 'ids', 'author' => $author_id, 'post_type' => 'talk', ));
$num = 0;
foreach($post_ids as $post_id) :
echo "<a href='". get_permalink( $post_id )."'>talk to your teacher</a></br>";
// the following condition, consider the last post that has created for the teacher to talk with students
$num = $num + 1;
if ($num >= 1){
break;
}
endforeach;
?>
I have an issue in my new theme.
my website is about Education for teachers and students. every post belongs to one teacher that students can talk to her/him via comments.
now, i want to add a special thing to any post. i want to have two comments_template() in one post with pills (bootstrap). in one, student can just ask their questions but in another, they can do review and rating.
in fact i need to use different comments_template file for every one.
but the problem is: by adding two comments_template to one post, every comment will be displayed in another part too. but i want to just to be displayed in its part (pill).
so can you help me in this case???
i really need it. thanks y friends
UPDATE:
for example, i added these codes to the single.php to have 2 comment_template(). one for discussing and another for rating to the teacher. but when i comment in one part, it will be shown in another too. and i want to use different comment_tamplate() for avery part:
<div class="row container-fluid profile_nazar" style=" margin: 0 5% 30px 5% !important; margin-bottom: 20px; border: 1px solid #ddd; box-shadow: 0 0 6px #ccc;">
<ul class="nav-pills profile_pills">
<li><a data-toggle="pill" href="#pill1">Talk</a></li>
<li><a data-toggle="pill" href="#pill2">Rate</a></li>
</ul>
<div style="width:100%; height:400px; overflow-y: scroll;">
<div class="tab-content">
<div id="pill1" class="tab-pane fade in active" style="margin: 20px;">
<?php comments_template(); ?>
</div>
<div id="pill2" class="tab-pane fade" style="margin: 20px;">
<?php comments_template(); ?>
</div>
</div>
</div>
</div>
I have an issue in my new theme.
my website is about Education for teachers and students. every post belongs to one teacher that students can talk to her/him via comments.
now, i want to add a special thing to any post. i want to have two comments_template() in one post with pills (bootstrap). in one, student can just ask their questions but in another, they can do review and rating.
in fact i need to use different comments_template file for every one.
but the problem is: by adding two comments_template to one post, every comment will be displayed in another part too. but i want to just to be displayed in its part (pill).
so can you help me in this case???
i really need it. thanks y friends
UPDATE:
for example, i added these codes to the single.php to have 2 comment_template(). one for discussing and another for rating to the teacher. but when i comment in one part, it will be shown in another too. and i want to use different comment_tamplate() for avery part:
<div class="row container-fluid profile_nazar" style=" margin: 0 5% 30px 5% !important; margin-bottom: 20px; border: 1px solid #ddd; box-shadow: 0 0 6px #ccc;">
<ul class="nav-pills profile_pills">
<li><a data-toggle="pill" href="#pill1">Talk</a></li>
<li><a data-toggle="pill" href="#pill2">Rate</a></li>
</ul>
<div style="width:100%; height:400px; overflow-y: scroll;">
<div class="tab-content">
<div id="pill1" class="tab-pane fade in active" style="margin: 20px;">
<?php comments_template(); ?>
</div>
<div id="pill2" class="tab-pane fade" style="margin: 20px;">
<?php comments_template(); ?>
</div>
</div>
</div>
</div>
Share
Improve this question
edited Dec 10, 2018 at 12:04
sh.dehnavi
asked Dec 8, 2018 at 12:19
sh.dehnavish.dehnavi
411 silver badge12 bronze badges
14
- Can you share some code you already have it will be easier to help then? – Greg Winiarski Commented Dec 10, 2018 at 11:48
- @GregWiniarski i updated my question, my friend. – sh.dehnavi Commented Dec 10, 2018 at 12:05
- This is a bit complicated, you would need to register different comment types and make sure each comment_template() is saving and listing the comment with correct comment_type, that being said i am afraid i am not sure how to code it, you would need to dig into the WP source code i suppose. – Greg Winiarski Commented Dec 10, 2018 at 13:40
-
@GregWiniarski yes my friend. i also think it is complicated. but for solving that, i want to create another
post typeand make a post for every teacher to have discussion with her/him students. but the issue is: i want to add a button in the profile page as"talk to your teacher"but i can not usethe_permalink();for that, because another post for that teacher belongs to anotherpost type. how can i automatically find that post permalink (in another post type). consider that in those two posts (different post type), the teacher ispost author. – sh.dehnavi Commented Dec 10, 2018 at 17:22 -
@sh.dehnavi, you can use
the_permalink()to get the permalink of any post types. You just need to use the correct post ID -the_permalink( 123 ). – Sally CJ Commented Dec 14, 2018 at 3:38
1 Answer
Reset to default 0i could not solve the main problem (two comments_template() in one post) but i created a new post_type for "talk to teacher" part and so we will create a post for every teacher in that post type and put the link of that post in teacher's profile page. by clicking on that link, students will go to new post that can just comment for the teacher and talk with her/him.
.
so by the following code, we can find that post in the new post_type to be used in the profile page:
consider: also in the new post, the author is the same.
<?php
$author_id = get_the_author_meta( 'ID' );
$post_ids = get_posts(array( 'fields' => 'ids', 'author' => $author_id, 'post_type' => 'talk', ));
$num = 0;
foreach($post_ids as $post_id) :
echo "<a href='". get_permalink( $post_id )."'>talk to your teacher</a></br>";
// the following condition, consider the last post that has created for the teacher to talk with students
$num = $num + 1;
if ($num >= 1){
break;
}
endforeach;
?>
本文标签: commentshow to have 2 commentstemplate() in one post
版权声明:本文标题:comments - how to have 2 comments_template() in one post 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749099806a2315816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


post typeand make a post for every teacher to have discussion with her/him students. but the issue is: i want to add a button in the profile page as"talk to your teacher"but i can not usethe_permalink();for that, because another post for that teacher belongs to anotherpost type. how can i automatically find that post permalink (in another post type). consider that in those two posts (different post type), the teacher ispost author. – sh.dehnavi Commented Dec 10, 2018 at 17:22the_permalink()to get the permalink of any post types. You just need to use the correct post ID -the_permalink( 123 ). – Sally CJ Commented Dec 14, 2018 at 3:38