0

I am using this post like system in my WordPress theme and its working fine. My WordPress theme is only for registered user, i mean only registered user can read my post. Now want to display all users list who liked the post in single page under any specific div.

can someone help me with a solution?

thanks

closed as off-topic by Mark Kaplun, Jack Johansson, cjbj, Max Yudin, Howdy_McGee Sep 12 '17 at 15:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

According to the code samples in the article _user_liked post meta should hold all the user ids of those who liked it. Something like this should be able to solve it for you

<?php
$post_id = get_the_ID();
$users_liked = get_post_meta( $post_id, '_user_liked', true );

if ( '' !== $users_liked && ! empty( $users_liked ) ) {
  ?>
  <ul>
  <?php foreach ( array_values( $users_liked ) as $user_id ) : 
    $user = get_user_by( 'id', $user_id );
    if ( false === $user ) {
      continue;
    }
    ?>
    <li><?php echo $user->user_login; ?></li>
  <?php endforeach; ?>
  </ul>
  <?php
}
  • I try this but getting error : Parse error: syntax error, unexpected 'endif' (T_ENDIF) – gul rathod Aug 30 '17 at 17:05
  • @gulrathod Yes, my bad. Try the updated code – Zlatev Aug 30 '17 at 18:58
  • thank you :) its working, i am getting user name list who like a current post. i am getting only user name, can you please tell me if i want user name with profile link or you can say author link, how can i get ??? – gul rathod Sep 1 '17 at 5:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.