Title: Add Post ratings
Last modified: March 2, 2017

---

# Add Post ratings

 *  [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * (@vbdeco)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/)
 * Hi,
 * I’m using Nisarg theme for my blog. I want to add a post rating by using _“wp-
   postratings”_ plugin.
 * This is what developper say to install it :
 * > Find: <?php while (have_posts()) : the_post(); ?>
   >  Add Anywhere Below It (The
   > Place You Want The Ratings To Show): <?php if(function_exists(‘the_ratings’)){
   > the_ratings(); } ?>
 * Could you tell me in wich file could i add this code to have post ratings after
   my post ?
 * Regards.

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Subrata Sarkar](https://wordpress.org/support/users/subrataemfluence/)
 * (@subrataemfluence)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8865450)
 * That’s up to you. Say you want to display the rating stars just below the title
   of your post. If so you can do this:
 *     ```
       <?php
         while(have_posts()): the_post();
         echo the_title();
         echo '<hr />';
         if(function_exists(‘the_ratings’)) { the_ratings(); }
       ?>
       ```
   
 *  Thread Starter [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * (@vbdeco)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8865469)
 * Hi,
    No i want to display rathing just before the comments.
 *  [Subrata Sarkar](https://wordpress.org/support/users/subrataemfluence/)
 * (@subrataemfluence)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8865477)
 * I presume your comment section comes beneath the actual `post_content`. If so
   you might reposition your rating starts under `post_content` so that the snippet
   looks like:
 *     ```
       <?php
         while(have_posts()): the_post();
         echo the_title();
         echo '<hr />';
         echo the_content();
         echo '<hr />';
         if(function_exists(‘the_ratings’)) { the_ratings(); }
         echo '<hr />';
         // Your Comment section starts here
       ?>
       ```
   
    -  This reply was modified 9 years, 4 months ago by [Subrata Sarkar](https://wordpress.org/support/users/subrataemfluence/).
 *  Thread Starter [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * (@vbdeco)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8865487)
 * But in which PHP file ?
    -  This reply was modified 9 years, 4 months ago by [vbdeco](https://wordpress.org/support/users/vbdeco/).
 *  Thread Starter [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * (@vbdeco)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8865884)
 * Don’t you know ?
 *  [Subrata Sarkar](https://wordpress.org/support/users/subrataemfluence/)
 * (@subrataemfluence)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8866292)
 * It is the page where your blog posts are being listed or the page where you are
   showing a blog’s detail information. It is hard to know what file structure you
   are using, if you have a child theme etc.
 * Usually detail page comes from `single.php`.
 * To know what php file is working behind a page there is a nice plugin available.
   
   [https://wordpress.org/plugins/what-the-file/](https://wordpress.org/plugins/what-the-file/).
 * Please go ahead and install it. You will know yourself where you to put the code
   for rating plugin 🙂
 *  Thread Starter [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * (@vbdeco)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8866383)
 * Thank you.
 * So there are :
    template-parts/content.php and single.php.
 * Problems : when i add code in these files, “rating stars” are out row :
 * ![capture](https://i0.wp.com/img4.hostingpics.net/pics/986887Capturede769cran.
   png)
 * I need stars after “escapades”. It is not first time i used this pluggin, but
   it’s the first time i can’t use it with Niasarg theme.
    -  This reply was modified 9 years, 4 months ago by [vbdeco](https://wordpress.org/support/users/vbdeco/).
 *  Thread Starter [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * (@vbdeco)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8866424)
 * Code for single.php :
 *     ```
       <?php
       /**
        * The template for displaying all single posts.
        *
        * @package Nisarg
        */
   
       get_header(); ?>
   
       	<div class="container">
               <div class="row">
       			<div id="primary" class="col-md-9 content-area">
       				<main id="main" role="main">
   
       				<?php while ( have_posts() ) : the_post(); ?>
   
       					<?php get_template_part( 'template-parts/content',get_post_format()); ?>
       				</main><!-- #main -->
       <div class="post-navigation">				
       					<?php nisarg_post_navigation(); ?>
       				</div>
   
       				<div class="post-comments">
       					<?php
       						// If comments are open or we have at least one comment, load up the comment template.
       						if ( comments_open() || get_comments_number() ) :
       							comments_template();
       						endif;
   
       						if(!comments_open())
       							_e('Comments are closed.','nisarg');
   
       					?>
       				</div>			
   
       				<?php endwhile; // End of the loop. ?>
   
   
       			</div><!-- #primary -->
   
       			<?php get_sidebar('sidebar-1'); ?>
       		</div> <!--.row-->            
           </div><!--.container-->
           <?php get_footer(); ?>
       ```
   
 * Code for template-parts/content.php
 *     ```
       <?php
       /**
        * Template part for displaying posts.
        *
        * @package Nisarg
        */
   
       ?>
   
       <article id="post-<?php the_ID(); ?>"  <?php post_class('post-content'); ?>>
   
       	<?php
       	if ( is_sticky() && is_home() && ! is_paged() ) {
       		printf( '<span class="sticky-post">%s</span>', __( 'Featured', 'nisarg' ) );
       	} ?>
   
       	<?php nisarg_featured_image_disaplay(); ?>
   
       	<header class="entry-header">	
   
       		<span class="screen-reader-text"><?php the_title();?></span>
   
       		<?php if ( is_single() ) : ?>
       			<h1 class="entry-title"><?php the_title(); ?></h1>
       		<?php else : ?>
       			<h2 class="entry-title">
       				<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
       			</h2>
       		<?php endif; // is_single() ?>
   
       		<?php if ( 'post' == get_post_type() ) : ?>
       		<div class="entry-meta">
       			<h5 class="entry-date"><?php nisarg_posted_on(); ?></h5>
       		</div><!-- .entry-meta -->
       		<?php endif; ?>
       	</header><!-- .entry-header -->
   
       			<div class="entry-content">
       				<?php					
       					the_content('...<p class="read-more"><a class="btn btn-default" href="'. esc_url(get_permalink( get_the_ID() )) . '">' . __(' Read More', 'nisarg') . '<span class="screen-reader-text"> '. __(' Read More', 'nisarg').'</span></a></p>');
       				?>
       <?php
       					wp_link_pages( array(
       						'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'nisarg' ),
       						'after'  => '</div>',
       					) );
       				?>
       			</div><!-- .entry-content -->
   
       	<footer class="entry-footer">
       		<?php nisarg_entry_footer(); ?>
       	</footer><!-- .entry-footer -->
       </article><!-- #post-## -->
       ```
   

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Add Post ratings’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/nisarg/1.6/screenshot.png)
 * Nisarg
 * [Support Threads](https://wordpress.org/support/theme/nisarg/)
 * [Active Topics](https://wordpress.org/support/theme/nisarg/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/nisarg/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/nisarg/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [vbdeco](https://wordpress.org/support/users/vbdeco/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/add-post-ratings/#post-8866424)
 * Status: not resolved