Support » Plugin: Post Views for Jetpack » Display Format

  • Resolved teeragit


    Is there a way to show only the views number, without anything else? I’d like to customise the text around the number myself.

Viewing 1 replies (of 1 total)
  • Plugin Author Jeremy Herve


    Jetpack Mechanic 🚀

    Yep, it’s possible. There are different ways to do that, but you could for example filter the output of the plugin, by adding a code snippet to your site using a functionality plugin. Here is the code snippet you could use to only display the number:

     * Customize the output of the post views counter.
     * @see
     * @param string $view    Original phrase outputting the number of views.
     * @param array  $views   Number of views.
     * @param string $post_id Post ID.
     * @return string
    function teeragit_custom_post_views_text( $view, $views, $post_id ) {
    	if ( ! empty( $views ) && isset( $views['total'] ) ) {
    		 * Here we'll build a string
    		 * with a div container and the number of views inside,
    		 * as an example.
    		 * You can of course create your own string, with whatever html you want.
    		return sprintf(
    			'<div class="teeragit_post_counter">%1$s</div>',
    	// Fallback to the original default text.
    	return $view;
    add_filter( 'jp_post_views_output', 'teeragit_custom_post_views_text', 10, 3 );

    You can of course customize this to display things before or after the number.

Viewing 1 replies (of 1 total)
  • The topic ‘Display Format’ is closed to new replies.