The Post Views Counter plugin provides flexible options for displaying views on your website’s frontend. Whether you want automatic insertion into your content, manual placement via shortcode, or sidebar widgets showcasing popular content, the display system adapts to your site’s design and audience needs.

Site owners can control exactly where Views appear, how they look, and who can see them. The display settings work independently from the tracking configuration, allowing you to track views silently while displaying them selectively, or show them only on specific content types and page contexts.

The display system integrates seamlessly with WordPress themes through automatic content insertion, the [post-views] shortcode, and a dedicated widget for showcasing top posts. Pro expands display capabilities with taxonomy archive support, author archive display, dynamic loading for cached sites, and the [site-views] shortcode for sitewide view totals.

Key Concepts

Display Methods

The plugin offers three primary ways to show views on your frontend:

  • Automatic Insertion: The counter is inserted relative to your content—either before or after—based on your position setting. This requires no theme modifications.
  • Manual Placement: Use the [post-views] shortcode in posts, pages, or widget areas to place the counter exactly where you want it. For theme developers, template functions like pvc_post_views() and pvc_get_post_views() provide programmatic access.
  • Widget: The Post Views List Widget displays top posts in any widget-ready area, perfect for sidebars and footers.

Position Options

The position setting at Post Views > Display > Counter Appearance determines how automatic insertion works:

  • Before the content: The counter appears above your post content
  • After the content: The counter appears below your post content (default)
  • Manual only: Disables automatic insertion; you control placement entirely via shortcode or template functions

Display Targets

You control which content types and page contexts display the counter:

  • Post Types: Select which post types (posts, pages, custom post types) show the counter. Default is "post".
  • Page Types: Choose contexts like singular posts, home page, archives, or search results. Default is "singular".
  • **Taxonomies**: Display view counts on category, tag, and custom taxonomy archive pages
  • **Author Archives**: Show view counts on author archive pages

Audience Visibility

The display audience settings let you hide the counter from specific visitor groups. You can restrict visibility based on login status (logged-in users vs. guests) or by specific user roles, giving you fine-grained control over who sees view counts.

How It Works

Automatic Content Insertion

When automatic insertion is enabled, the plugin hooks into WordPress content filters. The counter markup is injected at the specified position (before or after content) for matching post types and page contexts. The rendered output includes CSS classes that identify whether the count was loaded statically or dynamically.

The display logic evaluates:

  1. Whether the current page matches your selected page types (singular, home, archive, search)
  2. Whether the current content type is in your enabled post types list
  3. Whether the current visitor is excluded by your audience restrictions

If all conditions are met, the counter markup is inserted into the content. The plugin also supports bbPress content, allowing before/after insertion on topics and forums.

Shortcode Rendering

The [post-views] shortcode outputs the view counter for the current post by default. When the shortcode is processed, it retrieves the view count and formats it according to your display settings (label, icon, number formatting). The output matches the style configured in the Counter Appearance settings.

The [site-views] shortcode displays total site views across all content, with optional period parameter for time-based totals.

Widget Display

The Post Views List Widget queries for the most viewed posts and displays them in a list format. This widget uses the pvc_get_most_viewed_posts() function to retrieve popular content based on view counts stored in the database.

Template Functions

For developers who need programmatic control, the plugin provides several template functions:

  • pvc_post_views(): Outputs the view counter HTML for a post
  • pvc_get_post_views(): Returns the view count for a post
  • pvc_get_views(): Retrieves views with flexible parameters
  • pvc_most_viewed_posts(): Displays a list of most viewed posts
  • pvc_get_most_viewed_posts(): Returns array of most viewed posts
  • pvc_update_post_views(): Programmatically update view count
  • pvc_view_post(): Record a view for a post

Pro adds additional template functions:

  • pvc_get_site_views(): Retrieve total site views
  • pvc_get_most_viewed_terms(): Get most viewed taxonomy terms
  • pvc_get_most_viewed_users(): Get most viewed authors
  • pvc_get_most_searched_phrases(): Retrieve popular search queries

Dynamic Loading

For sites using page caching, the dynamic loading option ensures displayed counts remain accurate. When enabled at Post Views > Display > Counter Appearance, the counter loads the current view count via JavaScript after the page loads, bypassing cached HTML that might show outdated numbers.

This is particularly valuable for:

  • Sites with aggressive page caching
  • CDN-cached content
  • High-traffic pages where stale counts would be misleading

Number Formatting

The Format Number option at Post Views > Display > Counter Appearance applies locale-based formatting to view counts. When enabled, numbers display with appropriate thousand separators and decimal formatting based on your site’s language settings (e.g., "1,234" vs "1.234" depending on locale).

Configuration

Counter Appearance Settings

Configure the visual presentation of your view counter at Post Views > Display > Counter Appearance:

  • Views Label (label): The text displayed before the count number. Default is "Post Views:".
  • Display Style (display_style): Choose whether to show an icon, label text, or both. Options include Icon and Label.
  • Icon Class (icon_class): CSS class for the views icon. Supports any Dashicons class; default is "dashicons-chart-bar".
  • Format Number (use_format): Apply locale-based number formatting to the view count. Default is enabled.
  • Position (position): Where to insert the counter automatically. Options: Before the content, After the content (default), Manual only.
  • **Views Period** (`display_period`): Time range for displayed views. Default is Total Views.
  • **Dynamic Loading** (`dynamic_loading`): Load view counts dynamically to avoid cached values. Default is disabled.

Display Targets Settings

Control where the counter appears at Post Views > Display > Display Targets:

  • Post Types (post_types_display): Select which post types display the counter. Default is "post".
  • Page Type (page_types_display): Select page contexts where the counter appears. Default is "singular".
  • **Taxonomies** (`taxonomies`): Enable display on taxonomy archive pages. Default is disabled.
  • **Taxonomies Display** (`taxonomies_display`): Select specific taxonomies for counter display.
  • **Author Archives** (`user_display`): Enable display on author archive pages. Default is enabled in Pro.

Display Audience Settings

Restrict counter visibility at Post Views > Display > Display Audience:

  • User Type (restrict_display_groups): Hide the counter for selected visitor groups. Options: logged in users, guests, selected user roles.
  • User Roles (restrict_display_roles): When "selected user roles" is chosen, specify which roles to exclude from seeing the counter.

Admin Interface Settings

Settings at Post Views > Display > Admin Interface primarily affect the WordPress admin area:

  • Admin Column (post_views_column): Shows a Views column on post list screens. Default is enabled.
  • Admin Edit (restrict_edit_views): Allows editing view counts on the post edit screen. Default is disabled.
  • Toolbar Chart (toolbar_statistics): Displays a views chart in the admin toolbar for counted content types. Default is enabled.
  • Menu Position (menu_position): Choose where the plugin menu appears. Options: Top menu (default), Settings submenu.

Troubleshooting

Counter Not Appearing on Frontend

If the view counter doesn’t display where expected:

  1. Check Position Setting: If set to "Manual only" at Post Views > Display > Counter Appearance, automatic insertion is disabled. Change to "Before the content" or "After the content".

  2. Verify Post Types: Ensure your content type is selected at Post Views > Display > Display Targets under Post Types. The default includes only "post".

  3. Check Page Type: Confirm the current page context is enabled under Page Type at Post Views > Display > Display Targets. For single posts, "singular" should be selected.

  4. Review Audience Restrictions: At Post Views > Display > Display Audience, verify you haven’t excluded your user type or role from seeing the counter.

  5. Theme Compatibility: Some themes bypass standard WordPress content filters. If automatic insertion fails, use the [post-views] shortcode or template functions instead.

Counter Shows Cached or Stale Values

On cached sites, the displayed count may not reflect recent views:

  1. Enable Dynamic Loading: At Post Views > Display > Counter Appearance, enable Dynamic Loading to fetch current counts via JavaScript after page load.

  1. Adjust Cache Settings: If using page caching, consider shorter cache durations for pages displaying view counts.

  2. Use Shortcode in Uncached Areas: Place the [post-views] shortcode in areas of your page that bypass caching, such as dynamic sidebars.

Shortcode Not Working

If the [post-views] shortcode displays incorrectly or not at all:

  1. Verify Shortcode Syntax: Ensure you’re using [post-views] with correct brackets and spelling.

  2. Check Post ID Context: The shortcode defaults to the current post. Outside the loop or on archive pages, you may need to specify a post ID.

  3. Plugin Conflicts: Deactivate other plugins temporarily to check for shortcode conflicts.

Widget Shows No Results

If the Post Views List Widget displays no posts:

  1. Verify Tracking is Active: Ensure view tracking is enabled and has collected data.

  2. Check Post Type Settings: The widget queries posts that have accumulated views. New sites may need time to build view data.

  3. Review Widget Configuration: Check widget settings for any post type or taxonomy filters that might exclude content.

Counter Styling Issues

To customize counter appearance:

  1. Icon Class: Change the Icon Class at Post Views > Display > Counter Appearance to use any Dashicons class.

  2. Custom CSS: The counter output includes CSS classes for styling. Target .post-views or related classes in your theme’s stylesheet.

  3. Display Style: Toggle between Icon and Label options at Post Views > Display > Counter Appearance to control which elements appear.