How to Display Popular Posts by Views in WordPress without a Plugin

How to Display Popular Posts by Views in WordPress without a Plugin

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 file or better in a site-specific plugin: function wpb_set_post_views($postID) { $count_key = ‘wpb_post_views_count’; $count = get_post_meta($postID, $count_key, true); […]