Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Add post

You must login to add post .

Add question

You must login to ask question.

Login

Register Now

Register Now to become a member of Askgoogle forum and Enjoy it's benefit. We're looking forward to have you on our Forum!

How to count post views on wordpress without plugin 2020

How to count post views on wordpress without plugin 2020

How to count post views on wordpress without plugin, learn how to display post views with the eye sign (fa fa-eye) on WordPress theme, Show post views counter on your posts within the Next 5min with this simple snippets codes.

How to count post views on wordpress without plugin 2020

Welcome to our tutorial on how to Display post views counter on your wordpress theme without any plugin.

And this is the Best option because I don’t think there’s any plugin that counts post with this method. Plugins can only count with ( 1 Views) but not with (  1 Views)

You’re a content writer and you want to know which of your articles is performing better or get the highest Views. Or you owns a blog and want Display the total number views on each post. Or are you a Web developer that want to Add this feature to your theme? What ever the case maybe.

I just wanted to let you know that you’re on the right track. With this simple Codes am about to share with you, will get the Job done within the next 5 minutes.

How to count post views on wordpress without plugin with fa fa-eye 2020

So let’s get Started, Firstly you will need to copy this below code and paste it into your theme function.php file.

/** Post Views Count function**/
if ( ! function_exists( 'OurPostViews' ) ) :
/** * Get the value of view. */
function OurPostViews($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count ==''){
$count = 1;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '1');
} else {
$count++;
update_post_meta($postID, $count_key, $count);
}
}
endif;

Note Replace the OurPostViews from the code above to anything you want, example: PostView or PostViewCount or anything else, which ever name you gave it, it will work without issues.

How to count post views on wordpress without plugin 2020

Now our next Code would go to the Theme single.php or index.php file.

 

Now after placing that code into the Theme single.php, our last code would go to the place where you want the eye Views counter to show. It could be on the content.php or excerpt.php file depending on your theme structure.

 

The second one will show here if the code is placed in content.php file.

How to count post views on wordpress without plugin

As you can see on the above image that the post views counter is showing with eye sign

Also Read: How to fix WordPress Theme not Updating

Conclusion

The above code works without any issues, We have even Tested it before publishing this article, we just wanted to be sure is still Working as expected.

If you are finding it difficult to integrate the above codes, please do not hesitate to reach out to us through the comment section and tell where in particular you want us to help you with the code integration.
Also don’t forget to Share this article with others if you find it useful.

Click on the share Icon below to view the Share buttons.

ALSO READ How to find any music you’re looking for online 2020

About MOD3

Comment ( 1 )

  1. […] Also Read How to count post views on wordpress without plugin 2020 […]

Leave a reply

Stats

  • Questions ( 2 )
  • Answers ( 4 )
  • Best Answers ( 1 )
  • Users ( 12 )
Copyright 2020 Askgoogle | Powerd By Askgoogle Technologies.

Disclaimer: Every Askgoogle member is solely responsible for anything that he/she posts or uploads on Askgoogle.