• whitewavex

    (@whitewavex)


    Hello. Can I increase the number of views in the Statistics plugin?
    The fact is that my theme is built in such a way that the full text of the posts is opened on the category page using a script. When clicking on the title of the post, there is no transition to the single.php page, but the post simply expands. How can I increase the number of views when clicking on the title and expanding the post.
    I already use ajax to increase the number of views in another plugin. Here is my code:

      add_action( 'wp_ajax_increase_post_views_counter', 'increase_post_views_counter' );
    
      add_action( 'wp_ajax_nopriv_increase_post_views_counter', 'increase_post_views_counter' );
    
    function increase_post_views_counter(){
    
        if (function_exists('pvc_update_post_views') && isset($_POST['post_id'])) {
    
            $post_id = intval($_POST['post_id']);
    
            $post_count = pvc_get_post_views($post_id);
    
            $post_count++;
    
            pvc_update_post_views($post_id, $post_count); // Update view count Post Views Counter
    
        }
    
        die;
    
    }

The topic ‘Update posts view’ is closed to new replies.