How To get a list of popular tags by post views?

First thing we need to do is create a function that will detect post views count and store it as a custom field for each post. To do this, paste the following codes in your theme’s functions.php

> function wpb_set_post_views($postID) {
>     $count_key = 'wpb_post_views_count';
>     $count = get_post_meta($postID, $count_key, true);
>     if($count==''){
>         $count = 0;
>         delete_post_meta($postID, $count_key);
>         add_post_meta($postID, $count_key, '0');
>     }else{
>         $count++;
>         update_post_meta($postID, $count_key, $count);
>     } } //To keep the count accurate, lets get rid of prefetching remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

Now that you have this function in place, we need to call this function on the single post pages. This way the function knows exactly which post gets the credit for the views. To do this, you would need to paste the following code inside your single post loop:

wpb_set_post_views(get_the_ID());