Popular posts based on views only ?

Discussion in 'Sachiko' started by Mango Beauty Tips, Oct 15, 2016.

  1. Mango Beauty Tips

    Mango Beauty Tips New Member

    Joined:
    Oct 15, 2016
    Messages:
    2
    Likes Received:
    0
    Hello !

    I just bought the Sachiko theme and I'm very happy about it. The slider is quite something! ;)

    However, I really don't like the fact that the "popular" section is based on views instead of comments. I just downloaded the "Entry Views" plugin so it means that all my previous popular posts might not be featured from now.

    Ideally, I want to use the main slider for my latest posts and the popular sections for some posts I would chose, just like I checked "Featured" for the ones of the main slider.

    Is it possible to change that ? Based on number of comments instead of views or even better : Having the option to feature them of the section directly :D

    Best,
     
  2. maimairel

    maimairel Administrator
    Staff Member

    Joined:
    Apr 16, 2014
    Messages:
    1,584
    Likes Received:
    58
    Hello,

    Thanks for purchasing Sachiko and glad you like it :)

    For now the popular posts only shows posts based on the amount of views by using the plugin.
    You can change to order by the amount of comments by changing this easily in the PHP file.

    But as for adding another switch like the featured posts I don't think I'll implement such feature :)

    Open up includes/sachiko-template-tags.php, and find the function sachiko_popular_posts.

    Change the following code:

    Code (PHP):

    $query_args = wp_parse_args( $args, array(
        'posts_per_page' => 4,
        'meta_key'       => ev_get_meta_key(),
        'orderby'        => 'meta_value_num'
    ));
    To this:

    Code (PHP):

    $query_args = wp_parse_args( $args, array(
        'posts_per_page' => 4,
        'orderby'        => 'comment_count'
    ));
     
    Thanks!
     
  3. Mango Beauty Tips

    Mango Beauty Tips New Member

    Joined:
    Oct 15, 2016
    Messages:
    2
    Likes Received:
    0
    Great ! It works perfectly. Thank you again for your awesome work and support~
     
  4. maimairel

    maimairel Administrator
    Staff Member

    Joined:
    Apr 16, 2014
    Messages:
    1,584
    Likes Received:
    58
    Just change the meta text in your customizer to change the number of views to number of comments :)

    Thanks!
     

Share This Page