Reputation: 136
Basically I am trying to do filter the comments with 'meta_key' and value. I have get the comment meta data but reply link is not appear. Anyone help me out from this. I tried with wp_list_comments() but that I don't know how to use meta_key value.
Here is code:
<div class="comment-section">
<?php
$issue = array(
'meta_query' => array(
array(
'key' => 'comment-type',
'value' => 'Idea'
)
)
);
$comments_query = new WP_Comment_Query;
$comments = $comments_query->query( $issue );
if( $comments ) :
foreach( $comments as $comment ) :
?>
<div class="comment-author vcard">
<?php echo($comment->comment_content);?>
<div class="reply"><?php
// Display comment reply link
comment_reply_link( array_merge( $args, array(
'add_below' => $add_below,
'depth' => $depth,
'max_depth' => $args['max_depth']
) ) ); ?>
</div>
</div><!-- .comment-details -->
<?php
endforeach;
endif;
?>
</div>
Please let me know how to appear the reply link.
Upvotes: 0
Views: 1027
Reputation: 136
I've solved it
$comments = get_comments(array(
'post_id' => $post->ID,
'status' => 'approve',
'type' => 'comment',
'meta_key' => 'comment-type',
'meta_value' => 'Issue',
));
if($comments)
{
wp_list_comments(array(
'per_page' => 10, // Allow comment pagination
), $comments);
}
else
{
comment_form();
}
Upvotes: 2
Reputation: 131
u can try with this function i guess
function wp_filter_comment( $commentdata ) {
if ( isset( $commentdata['user_ID'] ) ) {
/**
* Filters the comment author's user ID before it is set.
*
* The first time this filter is evaluated, 'user_ID' is checked
* (for back-compat), followed by the standard 'user_id' value.
*
* @since 1.5.0
*
* @param int $user_ID The comment author's user ID.
*/
$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
} elseif ( isset( $commentdata['user_id'] ) ) {
/** This filter is documented in wp-includes/comment.php */
$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] );
}
return $commentdata;
}
Upvotes: 0