• I’m using the plugin for convenience. Thank you very much.

    I would like to know which posts have the most favorites. If possible, I’d like to list them on a fixed page so that visitors can refer to the most popular posts.

    How can I create a ranking of the posts with the most favorites? If possible, I would like this to be achieved in the form of a shortcode in the fixed page.

Viewing 1 replies (of 1 total)
  • epnageca

    (@epnageca)

    Hello, I tried that with a new template “mostfavorited” (then create a new page with that template).
    Here’s the code I used :

    $args = array(
    ‘post_type’ => ‘post’,
    ‘meta_key’ => ‘simplefavorites_count’,
    ‘meta_value’ => ‘0’,
    ‘meta_compare’ => ‘!=’,
    ‘orderby’ => ‘meta_value’,
    ‘posts_per_page’ => ’50’,

    );

    // 2. Execute WP Query
    $my_query = new WP_Query( $args );

    // Loop
    $i = 0;
    if( $my_query->have_posts() ) : while( $my_query->have_posts() ) :
    $my_query->the_post();
    $i++?>

    <div class=”post-preview”> <h6><?php echo”#$i “?>“><?php the_title(); ?> (Favorited <?php the_favorites_count($post_id, $site_id); ?> times)</h6>
    <?php the_post_thumbnail( ‘medium’ ); ?> </div> <?php

    endwhile; endif;
    wp_reset_postdata(); // Reset

Viewing 1 replies (of 1 total)
  • The topic ‘I want to create a ranking of posts with many favorites.’ is closed to new replies.