• Resolved Knordelia

    (@knordelia)


    Hi,

    I’d like to have the ratings of a post to be shown on the front page where you see the latest posts (should also apply if you go back to page with older posts). The possibility to rate should be given when the post is opened.

    I see how to get the rating possibility into the post (either by using the [ratings] code manually on every post or by adding it into single.php), but how do I get the current rating results shown on the (front) page before you open a post?

    I tried the solutions described here1, here2 and here3, but it doesn’t work,

    Here2: This just brings all the the rating stars into one corner of the front page.

    Here 3: Neither rating stars are clickable.

    I use the theme Hueman.

    How to solve this?

    Thanks in advance.

    https://www.ads-software.com/plugins/wp-postratings/

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

    (@gamerz)

    <?php echo the_ratings_results(get_the_id()); ?> will show the rating results based on the Rated Template.

    Thread Starter Knordelia

    (@knordelia)

    Thanks, I’ll try that asap and give a feedback on how it worked.

    Thread Starter Knordelia

    (@knordelia)

    It’s not working properly.

    What I did:

    Added your code in my theme’s (Hueman) index.php as shown below:

    <div class="post-list group">
    <?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
    <strong><?php echo the_ratings_results(get_the_id()); ?></strong>
    <?php get_template_part('content'); ?>
    <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    </div><!--/.post-list-->

    Added the code below to my theme’s single.php:
    <?php if(function_exists('the_ratings')) { the_ratings(); } ?>

    While the rating itself seems to work properly, showing the results on the front page does not work as I want to. It looks like this. The stars are not above each post, but “gathered” on the right side in every line of posts.

    The stars should be above every post (the post they are related to).

    How can I fix this?

    Thanks again in advance!

    Plugin Author Lester Chan

    (@gamerz)

    I think to put it down you need to place it the content template part and do a !is_single() check.

    Thread Starter Knordelia

    (@knordelia)

    Thanks for your reply.

    I’m not so good in this, sop just to make sure. I put this code <?php echo the_ratings_results(get_the_id()); ?>

    somewhere here in the template’s index.php?

    <section class="content">
    
    	<?php get_template_part('inc/page-title'); ?>
    
    	<div class="pad group">
    
    		<?php get_template_part('inc/featured'); ?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<div class="post-list group">
    				<?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>				
    
    				<?php get_template_part('content'); ?>
    				<?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    
    			</div><!--/.post-list-->
    
    			<?php get_template_part('inc/pagination'); ?>
    
    		<?php endif; ?>
    
    	</div><!--/.pad-->
    
    </section><!--/.content-->

    Where exactly do I put the code !is_single()?

    Thanks!

    Plugin Author Lester Chan

    (@gamerz)

    I think it is in content.php. That is the code to place.

    <?php if(!is_single()): ?>
    <?php echo the_ratings_results(get_the_id()); ?>
    <?php endif; ?>

    Thread Starter Knordelia

    (@knordelia)

    Thanks! That did the trick.

    I’ve inserted your code above in the content.php here (post meta group):

    <div class="post-meta group">
    
    <?php if(!is_single()): ?>
    <?php echo the_ratings_results(get_the_id()); ?>
    <?php endif; ?>  
    
    <p class="post-category"><?php the_category(' / '); ?></p>
    <p class="post-date"><?php the_time('j M, Y'); ?></p>
    
    </div><!--/.post-meta-->

    Now it seems to work as wished and looks nice. I will try remembering to give you a review on the plugin after some time in actual use (wills till take some time).

    Thanks again!

    Plugin Author Lester Chan

    (@gamerz)

    Thanks =)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘wp-postratings on front page not working’ is closed to new replies.