WordPress query page views can use the wp-postviews plug-in to display the number of page views.
Let’s take a look at how to install the wp-postviews plug-in for WordPress 4.7.
1. First, search for the wp-postviews plug-in in the plug-in bar and install it. Installation failure may be a directory permissions issue. Just enter the WordPress directory and change the permissions of the wp-content folder to 777:
chmod -R 777 wp-content</code>
2. After successful installation, in the plug-in column, activate the wp-postviews plug-in. This is the most important step, which is to display the number of views. At the end of the article, you need to modify the theme code. First open the folder where the theme is located:
cd /var/www/html/wordpress/wp-content/themes/twentyfifteen
3. At this time, you can see the relevant files in the directory of the currently used theme. Open content.php and add the code
<?php if(function_exists(‘the_views’)){ the_views();} ?>
at the location shown in the picture. Here you can see the number of views displayed at the end of the article.
For more wordpress related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of What do you need to use to query page views in WordPress?. For more information, please follow other related articles on the PHP Chinese website!