free tuts

If we want to show post views count we may use custom field and small function counting and displaying number of post views. Sometimes it maybe used as just an indicator of most popular posts, sometimes it is useful in shop—thus, we may define which products are of highest interest to potential buyers. In order to get it work, we need to add a couple of things to our theme.

Step 1, add custom field (post meta) to template file (for example to page-home.php or page-shop.php):

In this case we do not need to create new custom field on the backend (in dashboard). It will be created automatically but in order to get it we need to add specific function to functions.php.

Step 2, add function to functions.php:

Limpopo

©2014-2018