Does anyone know of a plugin that has a like feature or thumbs up down etc which stores these likes as custom meta data? Not a facebook like.

I'm currently using WTI Likes which stores the data in a new database table.

I need a way to sort posts by these likes and it seems the easiest right now is to find a plugin which stores likes in custom meta as there are plugins to sort by custom meta.

Thanks in advance

  • How do you want to sort the posts? Commented Jun 28, 2012 at 14:33
  • From most likes to least
    – Anagio
    Commented Jun 28, 2012 at 14:34

1 Answer 1


If you still use the plugin WTI Likes you can get the values direkt from the table that the plugin creates instead of saving values to the post meta.

Add this code where you want your list. Now it prints all post that have been liked. From most to least.


      global $wpdb;

      $query = "SELECT post_id, SUM(value) AS count FROM {$wpdb->prefix}wti_like_post GROUP BY post_id ORDER BY value DESC";
      $posts = $wpdb->get_results( $query );

     if( count( $posts ) > 0 ) {

       foreach ($posts as $post) {
          $post_title = get_the_title( $post->post_id );
          $post_link = get_permalink( $post->post_id );
          $count = $post->count;

          $output .= '<li>';
            // $count shows how many likes the post have
            $output .= '<span>'. $count .'</span>';
            $output .='<a href="'.$post_link.'">'.$post_title.'</a>';
          $output .= '</li>';
      } else {

      $output .= '<li>';
        $output .= __('No posts.', 'mytheme');
      $output .= '</li>';
      echo $output;

  • Hi, thanks i'll be trying this out and will get back to you. Is the $posts variable holding the post_ID's, or both post_ID and value? I ask because there are custom fields attached to each post and i'm curious to know if I can use another php function within the foreach loop to output some more data attached to the posts.
    – Anagio
    Commented Jun 28, 2012 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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