Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Gene,

    Thanks for taking a look at the plugin. There’s no shortcode for displaying this, but you can use the wp_count_posts() function to display the number of posts in your template files.

    <?php
    $count_reviews = wp_count_posts( GRFWP_REVIEW_POST_TYPE );
    
    echo $count_reviews->publish;
    ?>
    Thread Starter Gene

    (@gene158)

    Hi Nate, thanks for the code snippet, really appreciate it. I’ll give it a try and thanks for creating this plugin!

    No problem Gene. To be safe, you should wrap than in a defined() check, so it doesn’t throw an error if you ever deactivate the plugin:

    <?php
    if ( defined( 'GRFWP_REVIEW_POST_TYPE' ) ) {
      $count_reviews = wp_count_posts( GRFWP_REVIEW_POST_TYPE );
      echo $count_reviews->publish;
    }
    ?>

    what is actually ‘GRFWP_REVIEW_POST_TYPE’ and where to define it

    Hi rafinkarki,

    GRFWP_REVIEW_POST_TYPE is a constant which the plugin defines. This constant represents the unique slug of the review post type, which is currently grwp-review. It is defined when the plugin is initialized. Here is the precise spot in the code where it is defined.

    Currently there’s not a filter to easily adjust the post type, but I can put it on my todo list for a future update if you need to change it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display Total Count of Reviews’ is closed to new replies.