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? – Pontus Abrahamsson Jun 28 '12 at 14:33
  • From most likes to least – Anagio Jun 28 '12 at 14:34

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;

| improve this answer | |
  • 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 Jun 28 '12 at 17:37
  • I ended up using this function to get votes / likes stored in post meta 87studios.net/wptuts-2/… I posted a question on SO about creating a function if you want to take a look stackoverflow.com/questions/11271868/… – Anagio Jun 30 '12 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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