• Resolved rarikola

    (@rarikola)


    First of all Thank you very much for this great plugin.

    I’m trying to reorder posts by kk star rating, not by date.
    I mean each time post is rated, post goes up or down depending on rating.
    so I added custom meta-key to my posts template, and now posts are ordered by meta_key values . like this

    <?php query_posts('meta_key=asd&orderby=meta_value&order=ASC'); ?>

    now I need to pass kk rating to my custom meta_key(“asd” in my case) as value for each posts… and I don’t know how to do it.

    here is my site https://horror-movies.co/

    Thank you so much for your help.

    https://www.ads-software.com/extend/plugins/kk-star-ratings/

Viewing 12 replies - 16 through 27 (of 27 total)
  • Hi ,
    First of all ,Congratulations , I love this plugin.

    My only question is the same of that guy above: is that posts without a rating won’t appear anymore. Is there a way to solve this issue?

    Thanks

    Another alternative could be every time I send a post, it goes with five stars.

    Thanks

    Plugin Contributor Kamal Khan

    (@bhittani)

    Please change this

    query_posts('meta_key=_kk_ratings_avg&orderby=meta_value&order=DESC');

    into

    query_posts('meta_key=_kksr_avg&orderby=meta_value&order=DESC');

    Plugin Contributor Kamal Khan

    (@bhittani)

    all meta keys are changed from _kk_ratings_… to _kksr_…

    So

    _kk_ratings_ratings is now _kksr_ratings
    _kk_ratings_casts is now _kksr_casts
    _kk_ratings_avg is now _kksr_avg

    Thanks

    Hi , I`ve made the changes but still the same problem !

    I put the code query_posts(‘meta_key=_kksr_avg&orderby=meta_value&order=DESC’); on my page and posts without a rating didn`t appear

    Plugin Contributor Kamal Khan

    (@bhittani)

    Hmm, the posts without a rating don’t appear because they don’t have the meta key of _kksr_avg because they have not yet been rated and yet you are querying for the _kksr_avg.

    This is something custom and can be achieved if you apply a hack to all the previous posts. So a one time hack for all previous posts, applying a meta_key of _kksr_avg with a value of 0. And for all future posts created, you need to place a hook function so that everytime a post is being created, it creates a meta key of _kksr_avg with the value of 0.

    I hope this helps

    Thanks for your fast reply.

    Well , I a quite beginner in php.
    When I submitted a post , I know how to get the post`s ID.

    The problem is , how can I add a _kksr_avg = 0 ?

    Thanks again, and that will be my last question !

    Plugin Contributor Kamal Khan

    (@bhittani)

    Paste the code from the below link in your theme folder/functions.php ONLY ONE TIME.

    COPY CODE FROM HERE

    After placing that code in your functions.php file, refresh your wordpress website and then remove that code from functions.php otherwise it will run everytime and will make your website slow.

    This is a quick hack i could provide.

    Plugin Contributor Kamal Khan

    (@bhittani)

    This is the code to paste:

    global $wpdb;
    $Posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts);
    foreach ($Posts as $post)
    {
        if(!get_post_meta($post->ID, _kksr_avg, true))
        {
            update_post_meta($post->ID, '_kksr_avg', 0);
        }
    }

    Really nice.
    Thanks a million for your help.

    I `ve just saved my life haha !

    Plugin Contributor Kamal Khan

    (@bhittani)

    Glad it worked!

    I am also trying to have my homepage show posts by the amount of votes they have received, and I cannot figure out where to place the code snippets that you show above. It looks like there are two snippets of code that need to be placed to make this happen, where to do I place each code snippet?

    Thanks for your help.

    [No bumping. If it’s that urgent, consider hiring someone. Or try posting your own topic.]

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘[Plugin: kk Star Ratings] Ordering post by kk rating’ is closed to new replies.