• Creator
    Topic
  • #60874
    dannyboy
    Participant

    Hello MillaN, i followed your video to make a simple custom template which works fine. But there’s one problem, i want to display only numbers like so:
    4.6/5 (5)
    that is: rating/5 (total votes)

    however if i enable AJAX load addon, it will cause this error because i chose not to render the stars:

    error

    This is my template (un-commenting stars render solves the issue, but i don’t want to load them):

    <?php // GDRTS Template: numbers-only // ?>
    
    <div class="<?php gdrts_loop()->render()->classes(); ?>">
        <div class="gdrts-inner-wrapper">
    
            <?php do_action('gdrts-template-rating-block-before');
    
            do_action('gdrts-template-stars-rating-default-before-rating-stars');
    
            //gdrts_loop()->render()->stars();
    
            do_action('gdrts-template-stars-rating-default-after-rating-stars');
    		
    		//RATINGS		
    		
    			$item = $item = gdrts_get_rating_item_by_post();
    				
    			if (isset($item->meta['stars-rating_rating'])) {
    				
    				$rating = $item->meta['stars-rating_rating'];
    				
    				$votes = $item->meta['stars-rating_votes'];
    				
    				echo "<b>$rating</b>/5 ($votes)";			
    			
    			} else {
    				
    				echo 'none';
    			}				
    
    
            gdrts_loop()->json();
    
            do_action('gdrts-template-rating-block-after');
            do_action('gdrts-template-rating-rich-snippet');
    
            ?>
    
        </div>
    </div>
    Topic Information
    Bug Report
    7.0
    5.1
    2.6
    Attachments:
Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #60887
    MillaN
    Keymaster

    I will need to test why would such template though the error when stars are missing. I will test this as soon as I can.

    Dev4Press - Premium plugins for WordPress.

    1 user thanked author for this post.
    #60888
    dannyboy
    Participant

    I will need to test why would such template though the error when stars are missing. I will test this as soon as I can.

    Thanks i’ll wait your findings.

    #60891
    dannyboy
    Participant

    A possible solution would be the option to disable ajax by template. I don’t really need Ajax where this template shows up (archives pages), it loads 20 times on every page bypassing cache plugin.
    I only enabled Ajax to use it on default template on single post. Maybe i can do something to not use Ajax on this specific template?

    #60893
    MillaN
    Keymaster

    If you use Dynamic Load addon (loads data through AJAX), it is made for websites with some sort of full page cache to ensure that real rating is displayed, and not the cached results. But, it should work regardless. I will test this addon tomorrow.

    Dev4Press - Premium plugins for WordPress.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

If you don't have an account on this website, you can register for a free account here:

Register