Easy Post Views Count Shortcode

Below, you’ll find a detailed guide on how to add the Easy Post Views Count Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Easy Post Views Count Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Easy Post Views Count Plugin and the shortcodes it provides:

Plugin Icon
Easy Post Views Count

"Easy Post Views Count is a straightforward WordPress plugin that enables you to track, manage, and display the number of times a post has been viewed. It's handy for engagement analysis."

★★★★✩ (6) Active Installs: 2000+ Tested with: 6.0.6 PHP Version: false
Included Shortcodes:
  • [epvc_views]

Easy Post Views Count [epvc_views] Shortcode

The Easy Post Views Count plugin shortcode is used to display the number of views for a particular post. The shortcode accepts an ‘id’ parameter, which specifies the post ID. It then uses the ‘epvc_display_post_views’ function to fetch and display the view count for this post.

Shortcode: [epvc_views]

Parameters

Here is a list of all possible epvc_views shortcode parameters and attributes:

  • id – Specifies the unique identifier of the post

Examples and Usage

Basic example – Displays the post views count of a specific post using its ID.

[epvc_views id=1 /]

Advanced examples

Displaying the post views count of multiple posts by specifying their IDs. The posts views will be displayed in the order of the IDs provided.

[epvc_views id=1,2,3 /]

Displaying the post views count of a post using its ID, and appending the output to existing content. This can be useful when you want to display the post views count along with other content in a post or page.

[epvc_views id=1 content="This post has: " /]

PHP Function Code

In case you have difficulties debugging what causing issues with [epvc_views] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'epvc_views', array($this, 'epvc_display_post_views_shortcode') );

Shortcode PHP function:

function epvc_display_post_views_shortcode( $atts, $content ){
		// Getting attributes of shortcode
		extract( shortcode_atts( array(
			'id'	=> '',
		), $atts ) );
		ob_start();

		echo epvc_display_post_views( $id );

		$content .= ob_get_clean();
		return $content;
	}

Code file location:

easy-post-views-count/easy-post-views-count/includes/class-epvc-public.php

Conclusion

Now that you’ve learned how to embed the Easy Post Views Count Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *