Manual Usage

3. Manual Usage

The Post Views Counter plugin allows users to automatically display the counter on pages and/or posts. However, if they’d like to add the counter to only a few selected pages/posts or on different areas of the page/post then they can do so manually.

3.1 Display views with a shortcode

The Post Views Counter plugin allows users to automatically display the counter on pages and/or posts. However, if they’d like to add the counter to only a few selected pages/posts or on different areas of the page/post then they can do so manually using the [post-views] shortcode.

7-manual-usage-shortcode

To use this shortcode, head over to the page or post you wish to embed the post views counter on. In its text editor, enter the [post-views] shortcode where you want the counter to be displayed.

8-manual-usage-preview

Click the Save Draft button to continue.  When you preview the post or page, it should look something like the image above.

The shortcode also provides an optional id parameter which may be used to show post views for any specified post anywhere on the page. For example [post-views id="42"] would display post views for the post of id equal to 42.

To use this, find the id of the post you wish to embed the count of. Head over to the page or post where you want to embed this post’s counter. In its text editor, enter the [post-views id="42"] shortcode where you want the counter to be displayed.

11-post-counter-eye

Click the Save Draft button to continue. It should look something like this:

12-preview-counter-eye

3.2 Display views with a function

Description

Displays a post’s total post views along with the label and/or icon. The function is located in the functions.php file of the plugin.

Usage

pvc_post_views( $post_id = 0, $echo = true );

Parameters

  • $post_id | int: Stores the post’s ID.
  • $echo | boolean: Determines whether the post views should be displayed or returned.

Return

A string of display options that include the post’s ID, total number of views, label, and icon.

3.3 Count views with a function

(via pvc_view_post() function also located in functions.php plugin file

Description

Allows the user to view a given post manually. The function is located in the functions.php file of the plugin.

Usage

pvc_view_post( $post_id = 0 );

Parameters

  • $post_id | int: Stores the post’s ID.

Return

FALSE if the post doesn’t exist; TRUE if the post exists.

Leave a Reply

Please, do not use this form for technical support. To get support for our plugins, use the support forum.

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

No comments yet.

Be the first to start the conversation.