Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Pierre Lebedel

    (@pierre-lebedel)

    Hi, thanks !
    It’s a good idea, but i’m afraid it causes problems in category pages, post tags pages and others list pages (archives…) if the option force the most liked posts before others.
    I don’t know if you’re able to modify php code, but if you can, you could use the meta ‘kodex_post_likes’ to write your own WP_Query to display posts in this order

    Thread Starter inzerat

    (@inzerat)

    Hi, I am not able write a php code. Please you can write me simple wordpress theme function.php for add this option force the most liked posts before others?

    Plugin Author Pierre Lebedel

    (@pierre-lebedel)

    In the new version (2.0), there is a example of code for make a custom WP_Query on the plugin settings page.
    Hope that helps!

    Thread Starter inzerat

    (@inzerat)

    Hi thank you, I am sorry but just this code doesnt work

    $custom_query = new WP_Query(array(
      'post_type' => array('post'),
      'meta_key'  => 'kodex_post_likes_count',
      'orderby'   => 'meta_value_num',
      'order'     => 'DESC'
    ));

    it is full code to theme functions.php?

    Plugin Author Pierre Lebedel

    (@pierre-lebedel)

    Oh, no. this code just shows you how to make your own request in your theme custom files.
    I tried to make you a php code that you can pastein functions.php file :

    add_action(‘pre_get_posts’, ‘kodex_home_posts_order’);
    function kodex_home_posts_order($query){
    if( $query->is_home() && $query->is_main_query() ){
    $query->set(‘meta_key’, ‘kodex_post_likes_count’);
    $query->set(‘orderby’, ‘meta_value_num’);
    $query->set(‘order’, ‘DESC’);
    }
    }

    This code will modify the main query on your homepage to consider the posts likes count.
    Hope that helps !

    Thread Starter inzerat

    (@inzerat)

    Yeah that is it. But there’s one mistake. Do not display posts with a zero “like” rating. Please you can help with it?

    Plugin Author Pierre Lebedel

    (@pierre-lebedel)

    Sorry for the long waiting.
    For the zero vote problem, you must to re-publish the posts who have been written before the plugin installation.
    This will set the counter to “0” instead of “”, and the posts will be displayed.
    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I have an idea to improve’ is closed to new replies.