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" rel="nofollow noreferrer noopener">Talk</a></li>
<li><a data-toggle="pill" href="#pill2" rel="nofollow noreferrer noopener">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>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
i 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;
?>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0