Title: [Plugin: WP-PostViews] get_the_views()?
Last modified: August 20, 2016

---

# [Plugin: WP-PostViews] get_the_views()?

 *  [Denny Brown](https://wordpress.org/support/users/dennispbrown/)
 * (@dennispbrown)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-postviews-get_the_views/)
 * I wanted to use a shortcode to put the_views() right where I want it. Calling
   the_views() does an echo instead of a return. So I looked to see if there was
   a get_the_views() function. There isn’t.
 * But looking at the code, you can get the “return” version by setting the first
   argument to false. i.e.
    the_views(false); works.
 * Suggestion: put this on the Installation or FAQ page to make it easier for the
   next guy…
 * -Denny
 * [http://wordpress.org/extend/plugins/wp-postviews/](http://wordpress.org/extend/plugins/wp-postviews/)

Viewing 1 replies (of 1 total)

 *  [ponce666](https://wordpress.org/support/users/ponce666/)
 * (@ponce666)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-postviews-get_the_views/#post-2883459)
 * Hi Denny,
 * I hope this is what I need to show the views in an excerpt.
 * Where exactly does it go in the functions.php?
 * ### Function: Display The Post Views
    function the_views($display = true, $prefix
   = ”, $postfix = ”, $always = false) { $post_views = intval(post_custom(‘views’));
   $views_options = get_option(‘views_options’); if ($always || should_views_be_displayed(
   $views_options)) { $output = $prefix.str_replace(‘%VIEW_COUNT%’, number_format_i18n(
   $post_views), $views_options[‘template’]).$postfix; if($display) { echo apply_filters(‘
   the_views’, $output); } else { return apply_filters(‘the_views’, $output); } }
   elseif (!$display) { return ”; } }
 * Ponce

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: WP-PostViews] get_the_views()?’ is closed to new replies.

 * ![](https://ps.w.org/wp-postviews/assets/icon.svg?rev=978002)
 * [WP-PostViews](https://wordpress.org/plugins/wp-postviews/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-postviews/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-postviews/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-postviews/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-postviews/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-postviews/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [ponce666](https://wordpress.org/support/users/ponce666/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-postviews-get_the_views/#post-2883459)
 * Status: not resolved