目次
自分がコメントした記事一覧を表示する方法
<?php $user_id = get_current_user_id();?>
<?php $args = array(
'status' => 'approve' ,
'user_id' => $user_id
);
$comments = get_comments( $args );?>
<?php if (!empty($comments)):?>
<?php foreach($comments as $comment):
$post = get_post($comment->comment_post_ID);
the_time('Y.m.d');//コメントした記事の投稿日
the_title();//コメントした記事のタイトル
print mb_strimwidth(get_comment_excerpt(), 0, 100, "…", "UTF-8");//コメント抜粋
comment_date('Y/m/d');//コメントした日
?>
<?php endforeach; ?>
<?php else:?>
コメントした記事はありません
<?php endif;?>
関数リファレンス/get comments - WordPress Codex 日本語版
コメント