logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$30
I like plugin - query to retrieve liked posts in order of likes

Hello,

I've asked this question before here but left it to late to get back to it. Sorry to all those who replied.

So I'm starting a new question using a more simplified plugin based round the same idea.

The plugin 'I like this' simply adds a feature to posts where someone can like a post, but not actually connect with anything outside of wordpress (facebook, digg etc). The plugin can then add a counter to posts when called in the loop.

Plugin WordPress Directory http://wordpress.org/extend/plugins/i-like-this/

Official Plugin Site https://my-tapestry.tenderapp.com/kb/plugins/i-like-this

My question is...

I need a query, on my page template 'most-loved.php' which is used on my 'Most Loved' page, to retrieve only the posts which have had a like hit - and to display in order of the posts with the most likes.

So far my 'most-loved.php' looks like this...



<?php
/**
* Template Name: Most Loved
* @package WordPress
* @subpackage XXX
*/

get_header(); ?>


<?php $mostloved = new WP_Query(); ?>

<?php if ( $mostloved->have_posts()) : while ($mostloved->have_posts()) : $mostloved->the_post(); ?>

// Most Loved Post's Loop contents here...
// Including this for my like counter... <?php if(function_exists(getILikeThis)) getILikeThis('get'); ?>

<?php endwhile; ?>

<?php next_posts_link(__('MORE LOVED')) ?>

<?php previous_posts_link(__('LESS LOVED')) ?>

<?php endif; ?>


<?php get_footer(); ?>



Can a simple query like this be adapted for what I need it to do.

Person to give me a fully working answer and code will get all the money :-)


Thanks for time, reply any questions if need info.


This question has been answered.

Josh Cranwell | 12/03/11 at 7:38am Edit

Previous versions of this question: 12/03/11 at 7:44am

(2) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    12/03/11
    7:43am

    This answer was downvoted by the top experts.

  • avatar
    Last edited:
    12/03/11
    7:55am
    Hai Bui says:

    You can use this query:


    $mostloved = new WP_Query(array(
    'order' => 'DESC',
    'orderby' => 'meta_value',
    'meta_key' => '_liked',
    'paged' => $paged
    ) );

    Previous versions of this answer: 12/03/11 at 7:55am

    • 12/03/11 8:26am

      Josh Cranwell says:

      Perfect! Big Love!

    • 12/03/11 8:27am

      Josh Cranwell says:

      and thanks very much!

    • 12/03/11 8:55am

      Josh Cranwell says:

      Hi Hai, do you have any idea why my page navigation is not working?

      <?php endwhile; ?>

      <?php next_posts_link(__('MORE LOVED')) ?>
      <?php previous_posts_link(__('LESS LOVED')) ?>

      <?php endif; ?>

      I set my query to display one post per page so I could test my pagination...

      <?php $mostloved = new WP_Query(array(

      'order' => 'DESC',
      'orderby' => 'meta_value',
      'meta_key' => '_liked',
      'paged' => $paged,
      'posts_per_page' => '1'

      ) ); ?>

      But no pagination links appear?

This question has expired.



Josh Cranwell, Julio Potier, Luis Abarca, Francisco Javier Carazo Gil voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.