Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi tgberk. Assuming the code the plugin author gave you is correct, and your Top Rated Posts page is a copy of your Most Viewed Posts page, with the updated query arguments, the problem is in your content pages. In the post regarding Most Viewed Posts we also changed the content pages to include the views plugin function call. That’s still being used for your new Top Rated Posts page.

    To fix it you’d need to make a copy of your child theme content.php (and content-standard.php if you’re using that layout) and name it something like content-top-rated.php. In that file, remove the views plugin function call and add the top rated plugin function call. Then, in your Top Rated Posts page, where it shows:

    <?php get_template_part('content'); ?>

    you’d change that to:

    <?php get_template_part('content-top-rated'); ?>

    Let me know how that works.

    Thread Starter tgberk

    (@tgberk)

    Hello,

    I can’t find this code in content.php or content-standard.php

    <?php get_template_part('content'); ?>

    it is my content.php file https://pastebin.com/kFEphpEg

    I can’t find this code in content.php or content-standard.php

    From my post above:

    Then, in your Top Rated Posts page

    Thread Starter tgberk

    (@tgberk)

    Sorry, my mistake ?? But I couldn’t make it. Now I’ve 4 files in my child theme.

    These two I’ve made and edited for the views plugin. You’ve said to me copy content.php or content-standart.php depending on which layout i am using. I made both them because I don’t know which layout I am using. They’ve function call for the views plugin.
    content.php (https://pastebin.com/EAHZecy0)
    content-standart.php (https://pastebin.com/zzDP2xBu)

    These two I made for rating plugin. I added the function top rated plugin function call. This code (you can see at the ends of files):
    <?php if(function_exists('the_ratings_users')) { the_ratings_users(); } ?>
    content-top-rated.php (https://pastebin.com/dZseBsKS)
    content-standart-top-rated.php (https://pastebin.com/fAjGcPki)

    And finally it is top rated page template:
    top-rated.php (https://pastebin.com/7yGWTD9z)

    I think there is a problem with `rating_users’. May be It doesn’t call rating plugin I don’t know. Plugin author gave me these two codes.

    <?php if (function_exists('get_highest_rated')): ?>
        <ul>
            <?php get_highest_rated(); ?>
        </ul>
    <?php endif; ?>

    and

    <?php query_posts( array( 'meta_key' => 'ratings_users', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>

    I used second one because it looks similar to wp-views plugin code this one:

    <?php query_posts( array( 'meta_key' => 'views', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>

    So I simply changed “views” to “rating_users”. But It doesn’t work :/

    First off, thanks for taking time to post your code on Pastebin. Very helpful to see what you’re actually using.

    I made both them because I don’t know which layout I am using

    If you’re using the default blog layout (2 posts side-by-side) then the theme uses content.php. If you’re using the Standard Blog List (set in Theme Options > Blog) then it uses content-standard.php.

    So I simply changed “views” to “rating_users”.

    In the Top Rated Posts template file this is all that’s required to adjust the query. You would also change the content template file being called, which you’ve already done, so that template page looks OK. My guess is there’s something not right with the function call in content-top-rated.php files:

    <?php if(function_exists('the_ratings_users')) { the_ratings_users(); } ?>

    Not sure where you got that. On the plugin Installation page it shows this code:

    if(function_exists('the_ratings')) { the_ratings(); } ?>

    Try that code and see if it works.

    One other thing I noticed. Don’t know if you did this on purpose but thought I’d mention it. In the four “content” related files you have in your child theme, the “views” and “ratings” function calls are within the excerpt “if” statement. If you ever set your excerpt length to zero (Theme Options > Blog) those function calls won’t be run.

    Thread Starter tgberk

    (@tgberk)

    Hello again,

    No, It doesn’t work :/ No I didn’t do excerpt thing on purpose. Actually, before I started this post, I haven’t made function call for views. It was working without it. It is still working. Anyway, I changed the place of functions calls. I moved to the end, I mean this https://pastebin.com/dQnNEuti

    The function call is missing the closing bracket and php tag:

    <?php if(function_exists('the_ratings')) { the_ratings();

    should be:

    <?php if(function_exists('the_ratings')) { the_ratings(); } ?>

    The location of the function call now places it outside the article container. Since you want it to be part of the post content I would suggest moving it up to just after the “endif” statement.

    @tgberk do you have make this work?
    Is it possible that you send me your link? I want such a function for my project too.

    thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Top Rated Page’ is closed to new replies.