2017-07-13 37 views
0

私は自分のプロジェクトに私自身のcomments.phpを作りました。コメント作成者のカスタムメタデータをcustom_comments.phpに入れたいと思います。コメントを投稿するには投稿者メタのコメント.php

私はGoogle上のすべてのページを検索しますが、回答は見つかりませんでした。

これは私のコードです:コーデックスから

<?php $author = get_comment_author($comment_ID); ?> 

:たとえば

<?php 
$args = array (
'post_id' => $post_id 
); 
$comments = get_comments($args); 
if (!empty($comments)) : 
foreach($comments as $comment) : 
?> 
    <li> 
    <?php echo get_the_author_meta('mo_ldap_local_custom_attribute_title', $user->ID); ?> 
    </li> 
<?php endforeach; endif; ?> 

答えて

0

、最初のユーザー名を取得

$user = get_user_by('login',$author); 
if($user){ 
    echo $user->ID; 
    $userID = $user->ID; 
} 

、その後、次の方法で、著者情報を取得することができます。

https://codex.wordpress.org/Function_Reference/the_author_meta

<?php the_author_meta($field, $userID); ?> 
+0

ありがとうございます –

関連する問題