У меня есть шаблон вывода комментариев и к нему я прицепил кнопку которая меняет мето поле комментария
<?php
function coments_meta($postID) {
$user_id = get_current_user_id();
$check = get_user_meta( $user_id, 'meta_check', true );
if ( !$check || !isset($check[$postID]) ){
$check[$postID] = 1;
update_user_meta($user_id, 'meta_check', $check);
if ($_POST['coments']){
$number = get_comment_meta($postID, 'my_key', true);
$number++;
update_comment_meta($postID, 'my_key', $number );
}
}
}
function mytheme_comment( $comment, $args, $depth ) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
$classes = ' ' . comment_class( empty( $args['has_children'] ) ? '' : 'parent', null, null, false );
?>
<<?php echo $tag, $classes; ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) { ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body"><?php
} ?>
<?php
coments_meta($comment->comment_ID);
echo "meta: ".get_comment_meta ($comment->comment_ID, 'my_key', true);
?>
<form method="POST">
<input name="coments" value="plys" type="submit"/>
</form>
<div class="reply">
<?php
comment_reply_link(
array_merge(
$args,
array(
'add_below' => $add_below,
'depth' => $depth,
'max_depth' => $args['max_depth']
)
)
); ?>
</div>
<?php if ( 'div' != $args['style'] ) { ?>
</div>
<?php }
}?>
<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
Но проблема в том что он редактирует сразу мето поле всех комментариев.
Можно ли это как то исправить?