Use Ajax to manually solve the problem that WordPress WP-PostViews does not count, wordpresspostviews
A website has enabled Memcached and installed WP-PostViews. However, you do not know that the browser count of some articles does not work.
After some exploration, we found that WP-PostViews was counted by sending requests via ajax. The website that saw the problem simply sent the request.
After some exploration of wordpress background settings and plug-ins, I still cannot find the reason.
In desperation, add the script for this request manually to the bottom of the page. The Code is as follows:
<?php if (is_singular()) : ?> <!-- ajax post view --> <script type= "text/javascript" > $.ajax({ url: "http://***.com/wp-admin/admin-ajax.php" , data: { "postviews_id" : "<?php the_ID(); ?>" , "action" : "postviews" , "_" : new Date ().getTime() } }); </script><?php endif ; ?>
The above section describes how to manually solve the problem of WordPress WP-PostViews not counting through Ajax.
Articles you may be interested in:
- Using AJAX to asynchronously retrieve comments to user portraits in WordPress
- How to Use PHP + AJAX to allow WordPress to dynamically load articles
- Use CDN and AJAX to accelerate jQuery loading in WordPress
- How can I solve the problem when I use wordpress's $ wpdb class to read mysql database for ajax?
- Optimize time display of articles and comments in WordPress
- Detailed description of PHP functions that call comment templates and output comments cyclically in WordPress
- WordPress restricts non-administrator users to comment only once after the article
- Describes the PHP functions used in WordPress to obtain comment templates and search forms.
- Solve the problem that WordPress cannot comment after using CDN
- Use jQuery to implement @ ID floating display of comments in WordPress
- Compile a PHP script to implement the comment paging function in WordPress
- Example of modifying the PHP script to enable WordPress to intercept spam comments
- Customize the default comment Avatar and delay loading in WordPress
- Some methods to optimize guest comment in WordPress
- Implementation example of comments submission using AJAX technology in WordPress