Title: views count problem
Last modified: January 24, 2022

---

# views count problem

 *  Resolved [vl4d](https://wordpress.org/support/users/vl4d/)
 * (@vl4d)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/views-count-problem/)
 * my views count doesn’t work after installing the plugin i dont find any guid 
   how to make the views count on my theme or to be excluded from caching any tips??

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/views-count-problem/#post-15287842)
 * Hello [@vl4d](https://wordpress.org/support/users/vl4d/)
 * I am sorry about the issue you are experiencing and I am happy to assist you 
   with this.
    Can you please share the website URL and the theme you are using (
   or the plugin for views count) so I can check this? Thanks!
 *  Thread Starter [vl4d](https://wordpress.org/support/users/vl4d/)
 * (@vl4d)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/views-count-problem/#post-15299386)
 * i am ussing madara theme (i cant post here the link for my site sorry) this is
   the demo of my theme [https://mangabooth.com/](https://mangabooth.com/) [https://live.mangabooth.com/](https://live.mangabooth.com/)
 * if helps this is the extra code for the views i have on functions
 *     ```
       /**
       * Add columns “views” to table manga_chapters
       **/
       //add_action("after_switch_theme", "my_manga_add_columns");
       //function my_manga_add_columns(){
       //global $wpdb;
   
       //$db = WP_MANGA_DATABASE::get_instance();
       //if(!$db->column_exists($wpdb->prefix . 'manga_chapters', 'views')){
       //$db->alter_add_column($wpdb->prefix . 'manga_chapters', 'views', 'int');
       //}
       //}
   
       /**
       * Show the views
       **/
       add_action('wp_manga_after_chapter_name', 'my_manga_chapter_name_info', 10, 2);
   
       function my_manga_chapter_name_info($chapter, $manga_id){
       $views = manga_get_chapter_views($chapter['chapter_id']);
   
       echo '<i style="margin-right:50px;"><span class="view"><i class="fa fa-eye"></i> ' . $views . '</span></i>';
       }
   
       function manga_get_chapter_views($chapter_id){
       global $wpdb;
       $sql = "SELECT views from {$wpdb->prefix}manga_chapters WHERE chapter_id=%d" ;
   
       $views = $wpdb->get_var($wpdb->prepare($sql, $chapter_id));
   
       return $views ? $views : 0;
       }
   
       /**
       * Increase the views
       **/
       add_action('after_manga_single', 'my_manga_chapter_views');
       function my_manga_chapter_views(){
       $cur_chap = get_query_var( 'chapter' );
       $manga_id = get_the_ID();
   
       if($cur_chap != ""){
       global $wp_manga_chapter;
   
       $chapter = $wp_manga_chapter->get_chapter_by_slug( $manga_id, $cur_chap );
   
       if($chapter){
       $chapter_id = $chapter['chapter_id'];
       global $wpdb;
       $views = manga_get_chapter_views($chapter_id);
   
       $wpdb->update("{$wpdb->prefix}manga_chapters", array('views'=>++$views), array('chapter_id' => $chapter_id));
       }
       }
       }
       ```
   
    -  This reply was modified 4 years, 4 months ago by [vl4d](https://wordpress.org/support/users/vl4d/).
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/views-count-problem/#post-15301810)
 * Hello [@vl4d](https://wordpress.org/support/users/vl4d/)
 * Thank you for the information.
    Indeed the problem is that the views count is
   cached. The solution for this is programmatic. There are two ways t approach 
   this. The best way is to use AJAX and execute the view count with it to bypass
   any cache As a reference, you may check how other plugins/themes show dynamic
   data e.g. Woocommerce shows their shopping cart widget. Widget content is loaded
   via AJAX there with some support of local browser storage and as a result, they
   avoid the majority of problems with all caching plugins. The other possibility
   is to use Page Fragment Cache. With this, the specific part of the PHP code can
   be wrapped with <mfunc> which ensures that this part of the page stays uncached.
   Please check more information in our [FAQ](https://github.com/W3EDGE/w3-total-cache/wiki/FAQ:-Developers#what-is-page-fragment-cache).
   I hope this helps! Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘views count problem’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/views-count-problem/#post-15301810)
 * Status: resolved