Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Lester Chan

    (@gamerz)

    If you want to put the PHP code in your sidebar.php

    Use this

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

    Replace CATEGORY_ID with your ID

    As usual, this is a sample template. Please adjust it accordingly to your sidebar code. If you are not sure, contact your theme author as that is not within my support scope.

    Thread Starter creokiev

    (@creokiev)

    in category 3 more than 50 posts width more than 500 votes…
    I have the next PHP code in the sidebar.php

    <?php $catid = the_category_ID('');
    if ($catid == 3) : ?>
    <?php if (function_exists('get_highest_rated_category')): ?>
    <div id="ratings-widget-2" class="widget widget_ratings-widget"><h3 class="widget-title">Рейтинг фотографов</h3>
    <ul>
    <?php get_highest_rated_category(3, 'post', 4, 5); ?>
    </ul>
    </div>
    <?php endif; ?>

    output – Unknown (sidebar is empty)

    • This reply was modified 7 years, 9 months ago by creokiev.
    • This reply was modified 7 years, 9 months ago by creokiev.
    • This reply was modified 7 years, 9 months ago by creokiev.
    Plugin Author Lester Chan

    (@gamerz)

    if you replace $catid = the_category_ID(''); with $catid = get_the_category(); then do a var_dump($catid); to ensure it enter the loop first?

    Thread Starter creokiev

    (@creokiev)

    I’m trying to understand why we need to get an array if I only need to understand what category we are in. Through var_dump($catid); we get a lot of junk and nothing useful to solve this problem.
    print_r(var_dump($catid)) (without loop) is return:
    array(1) { [0]=> object(WP_Term)#5492 (16) { ["term_id"]=> int(56) ["name"]=> string(18) "Фотографы" ["slug"]=> string(5) "photo" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(56) ["taxonomy"]=> string(8) "category" ["description"]=> string(29) "База фотографов" ["parent"]=> int(0) ["count"]=> int(6) ["filter"]=> string(3) "raw" ["cat_ID"]=> int(56) ["category_count"]=> int(6) ["category_description"]=> string(29) "База фотографов" ["cat_name"]=> string(18) "Фотографы" ["category_nicename"]=> string(5) "photo" ["category_parent"]=> int(0) } }

    • This reply was modified 7 years, 9 months ago by creokiev.
    Plugin Author Lester Chan

    (@gamerz)

    So your $catid is wrong (nothing to do with the plugin). Because there are multiple categories and hence it is an array. So you need to do $catid[0]-> cat_ID

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to display 5 highest posts in category?’ is closed to new replies.