Docs / Configuration / Display Options

Display Options

Shortcodes, Gutenberg block, PHP template function, and automatic placement.

Automatic Placement

The simplest option. In Settings → Display, set the position to “Before content” or “After content” and the view count will appear on every tracked post type automatically.

Customise the output with the Label and Format fields.

Shortcode

Use Views: 0 anywhere in your content:

Views: 0
Views: 0
Total reads: 0

Attributes:

  • post_id — specific post ID (defaults to current post)
  • label — override the label text
  • format — override the format template

Gutenberg Block

Search for View Counter in the block inserter. The block renders a live preview in the editor showing the current count.

No configuration needed — it uses your global display settings by default.

PHP Template Function

For theme developers, use vc_get_post_views() in your templates:

<span class="post-views">
    <?php echo number_format_i18n( vc_get_post_views() ); ?> views
</span>

Or for a specific post: echo vc_get_post_views( 142 );

Tip

The shortcode and block both respect the auto-display format setting. The PHP function returns a raw integer — format it however you need in your template.