How can I create the number of custom post views

add this in your functions.php function getPostViews($postID){ $count_key = ‘post_views_count’; $count = get_post_meta($postID, $count_key, true); if($count==”){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, ‘0’); return “0 View”; } return $count; } function setPostViews($postID) { $count_key = ‘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); } }

How to Display Most View Post in the template file?

The function getPostViews() is retrieving the total number of views for each post while setPostViews() increases the post views counter each time post is viewed. You need to call setPostViews() somewhere in your single.php and then use below code to retrieve posts on basis of posts view count. $args = Array( ‘post_type’ => ‘post’, ‘posts_per_page’ … Read more

Add view to admin menu to filter for specific criteria ( If post is child of specific Parent )

You can “load the pages” via the pre_get_posts action, like so: add_action( ‘pre_get_posts’, ‘my_admin_pre_get_posts’ ); function my_admin_pre_get_posts( $q ) { // Check whether the filter was clicked. if ( isset( $_GET[‘post_parent’] ) ) { $screen = is_admin() ? get_current_screen() : null; // And that it’s the edit pages page. if ( $screen && ‘edit-page’ === … Read more

How to fix blog article view and share #’s?

The Newspaper theme uses ajax to display views and pull in social data. https://forum.tagdiv.com/ajax-view-count/ In order to keep requests to admin-ajax.php to a minimum, you should reduce the number of different blocks used on your site as well as reduce the ajax filters and pagination for each block. This will reduce server requests considerably. Please … Read more