• Resolved ffranciscocasas

    (@ffranciscocasas)


    Hi, I am trying to make a table with WP Table Builder that connects a page with each post and also appearing the rating in the table. I am trying to show the Total raitng ci=ount with numbers, the way it is shown on my posts.
    I am using the following shortcut inside the table: [yasr_visitor_votes readonly=”yes” size=”large” postid=”116″] , when trying to show the following content it doesnt show: [Total: %total_count% Average: %average% postid=”116″].
    I am really new on WordPress but I cannot figure this down.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor dudo

    (@dudo)

    Hi, I see some strange characters in your strings, be sure to always use this symbol instead of this .

    Further, if you need to use “large” size, you don’t need to declare it.

    So, the shortcode should appear like this

    [yasr_visitor_votes readonly="yes" postid="116"]

    Best,
    Dario

    Thread Starter ffranciscocasas

    (@ffranciscocasas)

    Yes, I could make the stars to appear. The problem is that I want to get the average number of the votes and show it as text or numbers.
    For example:

    Rating: 5.0

    Plugin Contributor dudo

    (@dudo)

    Ah ok, now I see.

    Now this is not possible, I will add an hook in the next version where an user can returns what is needed.

    Best,
    Dario

    Plugin Contributor dudo

    (@dudo)

    Update to version 2.5.1, I’ve added some filters.

    In your case, to accomplish your needs, you can add this code in your child theme

    add_filter('yasr_vv_shortcode', function($shortcode_html, $stored_votes) {
        $number_of_votes = $stored_votes['number_of_votes'];
        if ($number_of_votes > 0) {
            $average_rating = $stored_votes['sum_votes']/$number_of_votes;
        } else {
            $average_rating = 0;
        }
    
        $average_rating=round($average_rating, 1);
    
        return '<b>Rating:</b>'.$average_rating;
    }, 10, 2);
    
    add_filter('yasr_vv_txt_after', function($span_text_after_stars) {
        return false;
    }, 10, 1);

    Remember to disable stats in settings.

    Best,
    Dario

    Thread Starter ffranciscocasas

    (@ffranciscocasas)

    Ok, thanks. Let me get this:
    It is correct if I add a code snippet only in the page I will insert the table from “WP Table Builder”. Inside this table I will show the following code:
    [yasr_visitor_votes readonly="yes" postid="116"]
    And in the page that will show this table I put the code that you gave me?
    So the code will find for each yasr_visitor_votes and will change it to show the Rating : numbers??

    Thread Starter ffranciscocasas

    (@ffranciscocasas)

    Thanks I could do it!!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Count Rating’ is closed to new replies.