Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi!
    I am trying to do the same! any idea?

    Congratulations for the plugin

    I have solved it!

    I have created a page template “ranking” and I have added:

    $query = new WP_Query(array(
    		'post_status' =>'published',
    		'post_type' =>'post',
    		'orderby' => 'meta_value_num',
    		'meta_key' => '_liked',
    		'posts_per_page'=> '9',
    		'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
    	));

    and:

    <?php
    if ($query->have_posts())  {
    	echo '<ul>';
    	while ($query->have_posts()) {
    		$query->the_post();
    		echo '<li><a href="' . get_permalink() . '" title="'.get_the_title(). '">'.get_the_title(). ': ';
    		if (function_exists('wp_ulike_get_post_likes')):
    			echo wp_ulike_get_post_likes(get_the_ID());
    		endif;
    		echo ' likes</li>';
    	}
    	echo '</ul>';
    }else{
    	echo "Ranking empty";
    }
    ?>

    And it show-me a linkable list with the number of likes for each one. Any suggestions to improve it?

    Ed

    https://wordpress.org/plugins/wp-ulike/

    Thread Starter tonymark09

    (@tonymark09)

    Good Job perezasensio!

    Though I don’t know how to apply your solution.

    Where should I place your code in my wordpress installation?

    Should I create another file.

    Also how can I use it in my page. (Let’s say ‘Most Like Post’ page).

    Sorry for bugging you.

    Cheers!,
    Mark

    Hi Mark!
    You have to create a new type of page, so you should create a new template for this type of page (https://wordpress.org/support/topic/adding-new-page-templates?replies=7), you could copy the page template of your theme and modify it. I recommend you to create a Child Theme if you haven’t it.
    Insert the first code after
    get_header();
    and the second instead of the call for the content.

    Thread Starter tonymark09

    (@tonymark09)

    Thanks Ed,

    I’ll try that!

    Regards,
    Mark

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sorting Most Liked Post’ is closed to new replies.