Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

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

  • SOLVED

Hello,

I've asked this question before [[LINK href="http://wpquestions.com/question/showLoggedIn/id/3433"]]here[[/LINK]] 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 [[LINK href="http://wordpress.org/extend/plugins/i-like-this/"]]http://wordpress.org/extend/plugins/i-like-this/[[/LINK]]

Official Plugin Site [[LINK href="https://my-tapestry.tenderapp.com/kb/plugins/i-like-this"]]https://my-tapestry.tenderapp.com/kb/plugins/i-like-this[[/LINK]]

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.


Answers (2)

2011-12-03

Hai Bui answers:

You can use this query:


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


Josh Cranwell comments:

Perfect! Big Love!


Josh Cranwell comments:

and thanks very much!


Josh Cranwell comments:

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?

2011-12-03

Fahad Murtaza answers:

I am on it


Josh Cranwell comments:

Cool!