• Resolved fred_villa

    (@fred_villa)


    Hi Lester,

    I’m using your great plug-in for long on some sites to rate posts.
    Now I’m working on a new project about video games.

    Each “Video Games” is a category and there will be many posts for each “Video Games” as categories.
    Of course I know how to handle your plug-in for the posts but trying to use it for categories, I’m currently unable to know if what I would like to do could be done.

    The rating works for categories, so on a category page, visitors could rate the “video game” and I’m able to display a rate on each “video games” page.

    But is it possible to display each categories rate on the same page? I’m currently unable to do it.

    Using

    <?php
        $categories =  get_categories();
        foreach  ($categories as $category) {
           echo '<a href="'. get_category_link( $category->term_id ) .'"><img src="'. z_taxonomy_image_url($category->term_id, 'medium') .'" /><br/>'. $category->cat_name .'</a>';
                }		    
    ?>

    I’m able to display all “video games”/”categories” on the same page.

    But if I add in the foreach loop
    if(function_exists('the_ratings')) { the_ratings(); }

    it doesn’t display the ratings of each “video games”/”categories” but it displays the rating of the page I’m building under each “video games”/”categories”.

    I assume I’m missing something but my programming skills are not good enough to find it on myself.

    Thanks for your help.

    Fred

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

    (@gamerz)

    Sorry, it doesn’t work on categories because it uses post ID to keep track of the ratings as it is using the postmeta table. There is no way around it.

    Thread Starter fred_villa

    (@fred_villa)

    Thanks for your answer.
    It offers me to not continue to try to find a solution when there’s none.

    Thread Starter fred_villa

    (@fred_villa)

    OK, I’ve find a different way to do what I want.

    I’ve added categories and tags to Pages.

    function add_taxonomies_to_pages() {
     register_taxonomy_for_object_type( 'post_tag', 'page' );
     register_taxonomy_for_object_type( 'category', 'page' );
     }
    add_action( 'init', 'add_taxonomies_to_pages' );

    Then I created Pages for each Video Games declaring the Page to the associated category for the Video Game.
    I needed to learn how to use WP_Query for the loop, a little hard at first but really interesting for the final result.

    So now my Platform pages are linking all pages for the Video Games, and a Video Game page is linking to posts for the Video Game category.

    This way visitors will be able to rate Video Games and I could rank them by rate with the precious
    'meta_key' => 'ratings_average', 'orderby' => 'meta_value_num', 'order' => 'DESC'

    Now I need a different kind of help.
    Is there a function to call to display only %RATINGS_AVERAGE% on some places?
    Cause using the_ratings() displays the stars. As I use 10 stars, on some place of the site I would prefer to only display the %RATINGS_AVERAGE%.

    Thanks for your help.

    • This reply was modified 8 years, 8 months ago by fred_villa.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Rating categories ?’ is closed to new replies.