I want to display a list of most liked posts in my wordpress by using WP ULike plugin

Viewed 18

I want to display a list of most liked post in my homepage. I have tried but no success so far as I'm not a WordPress pro. Any help is appreciated, thanks a lot!

Here is my old code, In this code i used a plugin called WP Applause Button to show my most liked post. Now i have installed WP ULike plugin, and i want to do the same.

//-----------------------------------------------------
// claps
//-----------------------------------------------------
function mundana_claps()
{
global $post;
$disableauthorcard = get_theme_mod('disable_authorbox_sectionarticles_card');
$disablereadingtimecard = get_theme_mod('disable_readingtime_sectionarticles_card');
$disabledatecard = get_theme_mod('disable_date_sectionarticles_card');
if (class_exists('WPClapsApplause')) { ?>
<div class="sticky-top sticky-sidebar-offset mundana_claps_popular">
    <h4 class="spanborder h4 posttxt loading"><span>
            <?php _e('Popular on', 'mundana'); ?>
            <?php echo get_bloginfo('name'); ?></span></h4>
    <ol class="list-featured">
        <?php $args = array(
    'post_type' => 'post',
        'post_status'    => 'publish',
        'numberposts' => 5,
        'meta_key' => '_pt_claps',
        'orderby' => 'meta_value_num',
        'order' => 'DESC'
);
$most_loved = get_posts($args);
foreach ($most_loved as $loved) :
        $categories = get_the_category($loved); ?>
        <li class="loved-item mb-4">
            <span>
                
                <h6 class="posttit loading">
                    <a class="text-dark skeleton" href="<?php echo get_permalink($loved->ID); ?>">
                        <?php echo get_the_title($loved->ID); ?></a>
                </h6>
                <div class="text-muted _XYh">
                    <div class="njnhn posttxt loading">
                 <span>  <a class="text-dark _XYh text-capitalize skeleton" href="<?php echo get_author_posts_url($allfavorites_query->post_author); ?>"><?php echo get_the_author_meta('display_name'); ?></a> <?php _e( 'in', 'mundana' ); ?></span><span> <?php if ( ! empty( $categories ) ) {
                            echo '<a class="skeleton text-dark _XYh text-capitalize" href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>';
                            } ?> </span>
                </div>
  <div class="Lokjh posttxt loading">
                    <?php if ($disabledatecard == 0) { ?> 
                 <span class="skeleton">   <?php echo get_the_date('M j', $loved->ID); ?></span>
                    <?php 
                                                                                                                                                                                        } ?>
                    <?php if ($disabledatecard == 0) { ?> &middot;
 <?php if ($disablereadingtime == 0) {?>
            <span class="readingtime skeleton"><?php echo mundana_estimated_reading_time() ?></span>
            <?php

}?><span>
                    <svg style="fill: rgba(0,0,0,0.45); margin-left: 3px; display:inline-black; margin-top: -2px;" xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="<?php 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (get_the_modified_time('U', $loved->ID) > get_the_time('U', $loved->ID)) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                echo __('Updated ', 'mundana') . get_the_modified_time('M j, Y', $loved->ID);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        } else {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                echo get_the_date('M j, Y', $loved->ID);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ?>">>
                        <path d="M12 .288l2.833 8.718h9.167l-7.417 5.389 2.833 8.718-7.416-5.388-7.417 5.388 2.833-8.718-7.416-5.389h9.167z" /></svg></span>
                    <?php 
                }  ?></div>
                </div>
            </span>
        </li>
        <?php endforeach;
}
?>
    </ol>
</div>
<?php 
}
0 Answers
Related