Currently, there are 0 users and 1 guest visiting this topic.
Author
Topic
#60874

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
Viewing 7 replies - 1 through 7 (of 7 total)
Author
Replies
  • #60887

    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

    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

    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

    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.

  • #60979

    I couldn’t find any issues with the dynamic load under any tests. Can you test for conflicts with other plugins or themes?

    Dev4Press - Premium plugins for WordPress.

  • #60980

    It’s alright i won’t use this template any more so if you couldn’t reproduce you can close it.

  • #60981

    OK. If you run into any problem later on, let me know.

    Dev4Press - Premium plugins for WordPress.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Enable Ajax on a template that doesn’t render stars cause error.’ is closed to new replies.