| 1 |
=== WP-PostViews === |
| 2 |
Contributors: GamerZ |
| 3 |
Donate link: https://lesterchan.net/site/donation/ |
| 4 |
Tags: views, hits, counter, postviews |
| 5 |
Requires at least: 4.0 |
| 6 |
Tested up to: 4.7 |
| 7 |
Stable tag: 1.74 |
| 8 |
|
| 9 |
Enables you to display how many times a post/page had been viewed. |
| 10 |
|
| 11 |
== Description == |
| 12 |
|
| 13 |
= Build Status = |
| 14 |
[](https://travis-ci.org/lesterchan/wp-postviews) |
| 15 |
|
| 16 |
= Development = |
| 17 |
[https://github.com/lesterchan/wp-postviews/](https://github.com/lesterchan/wp-postviews/ "https://github.com/lesterchan/wp-postviews/") |
| 18 |
|
| 19 |
= Translations = |
| 20 |
[http://dev.wp-plugins.org/browser/wp-postviews/i18n/](http://dev.wp-plugins.org/browser/wp-postviews/i18n/ "http://dev.wp-plugins.org/browser/wp-postviews/i18n/") |
| 21 |
|
| 22 |
= Credits = |
| 23 |
* Plugin icon by [Iconmoon](http://www.icomoon.io) from [Flaticon](http://www.flaticon.com) |
| 24 |
|
| 25 |
= Donations = |
| 26 |
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations. |
| 27 |
|
| 28 |
== Changelog == |
| 29 |
= Version 1.74 = |
| 30 |
* NEW: Bump WordPress 4.7 |
| 31 |
* NEW: Template variable %POST_CATEGORY_ID%. It returns Post's Category ID. If you are using Yoast SEO Plugin, it will return the priority Category ID. Props @FunFrog-BY |
| 32 |
|
| 33 |
= Version 1.73 = |
| 34 |
* FIXED: In preview mode, don't count views |
| 35 |
|
| 36 |
= Version 1.72 = |
| 37 |
* NEW: Add %POST_THUMBNAIL% to template variables |
| 38 |
|
| 39 |
= Version 1.71 = |
| 40 |
* FIXED: Notices in Widget Constructor for WordPress 4.3 |
| 41 |
|
| 42 |
= Version 1.70 = |
| 43 |
* FIXED: Integration with WP-Stats |
| 44 |
|
| 45 |
= Version 1.69 = |
| 46 |
* NEW: Shortcode `[views]` or [views id="POST_ID"]` to embed view count into post |
| 47 |
* NEW: Added template variable `%VIEW_COUNT_ROUNDED%` to support rounded view count like 10.1k or 11.2M |
| 48 |
|
| 49 |
= Version 1.68 = |
| 50 |
* NEW: Added action hook 'postviews_increment_views' and 'postviews_increment_views_ajax' |
| 51 |
* NEW: Allow custom post type to be chosen under the widget |
| 52 |
|
| 53 |
= Version 1.67 = |
| 54 |
* NEW: Allow user to not use AJAX to update the views even though WP_CACHE is true |
| 55 |
|
| 56 |
= Version 1.66 = |
| 57 |
* NEW: Supports MultiSite Network Activation |
| 58 |
* NEW: Add %POST_DATE% and %POST_TIME% to template variables |
| 59 |
* NEW: Add China isearch engines bots |
| 60 |
* NEW: Ability to pass in an array of post types for get_most/least_*() functions. Props Leo Plaw. |
| 61 |
* FIXED: Moved uninstall to uninstall.php and hence fix missing nonce. Props Julio Potier. |
| 62 |
* FIXED: Notices and better way to get views from meta. Props daankortenbach. |
| 63 |
* FIXED: No longer needing add_post_meta() if update_post_meta() fails. |
| 64 |
|
| 65 |
= Version 1.65 (02-06-2013) = |
| 66 |
* FIXED: Views not showing in WP-Admin if "Display Options" is not set to "Display to everyone" |
| 67 |
|
| 68 |
= Version 1.64 (31-05-2013) = |
| 69 |
* NEW: Using Enqueue Script For WP_CACHE Enabled Sites. Props Crowd Favourite |
| 70 |
* FIXED: Viewcounter always display eventhough "display to registered users only" is set |
| 71 |
|
| 72 |
= Version 1.63 (07-05-2013) = |
| 73 |
* NEW: Added nonce To PostViews Options Admin Page |
| 74 |
|
| 75 |
= Version 1.62 (29-11-2012) = |
| 76 |
* NEW: Add "Views" Column To Manage Pages In WP-Admin |
| 77 |
* NEW: Add Sortable "Views" Column To Manage Posts/Pages In WP-Admin |
| 78 |
|
| 79 |
= Version 1.61 (21-05-2012) = |
| 80 |
* FIXED: Move AJAX Request to wp-admin/admin-ajax.php |
| 81 |
|
| 82 |
= Version 1.60 (18-02-2011) = |
| 83 |
* NEW: Added Views Count To Edit Posts Screen |
| 84 |
* FIXED: Removed Global $post |
| 85 |
|
| 86 |
= Version 1.50 (15-06-2009) = |
| 87 |
* NEW: Works For WordPress 2.8 Only |
| 88 |
* NEW: Uses jQuery Framework |
| 89 |
* NEW: Added In Most Viewed Pages To WP-Stats |
| 90 |
* NEW: Use _n() Instead Of __ngettext() And _n_noop() Instead Of __ngettext_noop() |
| 91 |
* FIXED: Uses $_SERVER['PHP_SELF'] With plugin_basename(__FILE__) Instead Of Just $_SERVER['REQUEST_URI'] |
| 92 |
* NEW: Uses New Widget Class From WordPress |
| 93 |
* NEW: Merge Widget Code To wp-postviews.php And Remove wp-postviews-widget.php |
| 94 |
* NEW: Added get_most_viewed_tag() And get_least_viewed_tag() |
| 95 |
* FIXED: Ensure That Post Is Not A Revision |
| 96 |
* FIXED: Multiple Loops Filtered Not Cleared |
| 97 |
|
| 98 |
= Version 1.40 (12-12-2008) = |
| 99 |
* NEW: Works For WordPress 2.7 Only |
| 100 |
* NEW: Options To Display Views On Certain Places by David Potter |
| 101 |
* NEW: Right To Left Language Support by Kambiz R. Khojasteh |
| 102 |
* NEW: Output Of the_views() Applied To "the_views" Filter by Kambiz R. Khojasteh |
| 103 |
* NEW: Called postviews_textdomain() In views_init() by Kambiz R. Khojasteh |
| 104 |
* NEW: Uses plugins_url() And site_url() |
| 105 |
* NEW: Added get_least_viewed() And get_least_viewed_category() By JBrinx |
| 106 |
* FIXED: "views" Custom Field Gets Created Now When Post Is Published |
| 107 |
|
| 108 |
= Version 1.31 (16-07-2008) = |
| 109 |
* NEW: Works For WordPress 2.6 |
| 110 |
* NEW: Renamed GET Variables sortby To v_sortby And orderby To v_orderby |
| 111 |
* NEW: Better Translation Using __ngetext() by Anna Ozeritskaya |
| 112 |
* FIXED: Able To Use v_sortby And v_orderby in query_posts() |
| 113 |
|
| 114 |
= Version 1.30 (01-06-2008) = |
| 115 |
* NEW: Uses /wp-postviews/ Folder Instead Of /postviews/ |
| 116 |
* NEW: Uses wp-postviews.php Instead Of postviews.php |
| 117 |
* NEW: Uses wp-postviews-widget.php Instead Of postviews-widget.php |
| 118 |
* NEW: Uses number_format_i18n() Instead Of number_format() |
| 119 |
* NEW: Option To Exclude Bots Views In 'WP-Admin -> Settings -> Post Views' |
| 120 |
* NEW: Added Most Viewed Template |
| 121 |
* NEW: Change The Way WP-PostViews Count Views |
| 122 |
* NEW: Should Work With WP-Cache Or WP-SuperCache |
| 123 |
|
| 124 |
= Version 1.20 (01-10-2007) = |
| 125 |
* NEW: Works For WordPress 2.3 Only |
| 126 |
* NEW: Most Viewed Widget Added |
| 127 |
* NEW: Ability To Uninstall WP-PostViews |
| 128 |
* NEW: Uses WP-Stats Filter To Add Stats Into WP-Stats Page |
| 129 |
|
| 130 |
= Version 1.11 (01-06-2007) = |
| 131 |
* FIXED: Wrong URL For Page Under Most Viewed Posts Listing |
| 132 |
|
| 133 |
= Version 1.10 (01-02-2007) = |
| 134 |
* NEW: Works For WordPress 2.1 Only |
| 135 |
* NEW: Localization WP-PostViews |
| 136 |
* NEW: Added Function To Get Most Viewed Post By Category ID |
| 137 |
* FIXED: Views Not Counting In Some Cases |
| 138 |
|
| 139 |
= Version 1.02 (01-10-2006) = |
| 140 |
* NEW: Change In get_most_viewed() To Accommodate Latest Version Of WP-Stats |
| 141 |
|
| 142 |
= Version 1.01 (01-07-2006) = |
| 143 |
* NEW: Added Get Total Views Function |
| 144 |
* FIXED: Modified Get Most Viewed Post Function |
| 145 |
|
| 146 |
= Version 1.00 (01-03-2006) = |
| 147 |
* NEW: Initial Release |
| 148 |
|
| 149 |
== Installation == |
| 150 |
|
| 151 |
1. Open `wp-content/plugins` Folder |
| 152 |
2. Put: `Folder: wp-postviews` |
| 153 |
3. Activate `WP-PostViews` Plugin |
| 154 |
4. Go to `WP-Admin -> Settings -> PostViews` to configure the plugin. |
| 155 |
|
| 156 |
= Usage = |
| 157 |
1. Open `wp-content/themes/<YOUR THEME NAME>/index.php` |
| 158 |
2. You may place it in archive.php, single.php, post.php or page.php also. |
| 159 |
3. Find: `<?php while (have_posts()) : the_post(); ?>` |
| 160 |
4. Add Anywhere Below It (The Place You Want The Views To Show): `<?php if(function_exists('the_views')) { the_views(); } ?>` |
| 161 |
5. Or you can use the shortcode `[views]` or `[views id="1"]` (where 1 is the post ID) in a post |
| 162 |
|
| 163 |
== Upgrading == |
| 164 |
|
| 165 |
1. Deactivate `wp-postviews` Plugin |
| 166 |
2. Open `wp-content/plugins` Folder |
| 167 |
3. Put/Overwrite: `Folder: wp-postviews` |
| 168 |
4. Activate `WP-PostViews` Plugin |
| 169 |
|
| 170 |
== Upgrade Notice == |
| 171 |
|
| 172 |
N/A |
| 173 |
|
| 174 |
== Screenshots == |
| 175 |
|
| 176 |
1. PostViews |
| 177 |
2. Admin - PostViews Options |
| 178 |
|
| 179 |
== Frequently Asked Questions == |
| 180 |
|
| 181 |
= How To View Stats With Widgets? = |
| 182 |
* Go to `WP-Admin -> Appearance -> Widgets` |
| 183 |
* The widget name is Views. |
| 184 |
|
| 185 |
= How To View Stats (Outside WP Loop) = |
| 186 |
|
| 187 |
= To Display Least Viewed Posts = |
| 188 |
* Use: |
| 189 |
<code> |
| 190 |
<?php if (function_exists('get_least_viewed')): ?> |
| 191 |
<ul> |
| 192 |
<?php get_least_viewed(); ?> |
| 193 |
</ul> |
| 194 |
<?php endif; ?> |
| 195 |
</code> |
| 196 |
* The first value you pass in is the post type that you want. If you want to get every post types, just use 'both'. It also supports PHP array: example `array('post', 'page')`. |
| 197 |
* The second value you pass in is the maximum number of post you want to get. |
| 198 |
* Default: get_least_viewed('both', 10); |
| 199 |
|
| 200 |
= To Display Most Viewed Posts = |
| 201 |
* Use: |
| 202 |
<code> |
| 203 |
<?php if (function_exists('get_most_viewed')): ?> |
| 204 |
<ul> |
| 205 |
<?php get_most_viewed(); ?> |
| 206 |
</ul> |
| 207 |
<?php endif; ?> |
| 208 |
</code> |
| 209 |
* The first value you pass in is the post type that you want. If you want to get every post types, just use 'both'. It also supports PHP array: example `array('post', 'page')`. |
| 210 |
* The second value you pass in is the maximum number of post you want to get. |
| 211 |
* Default: get_most_viewed('both', 10); |
| 212 |
|
| 213 |
= To Display Least Viewed Posts By Tag = |
| 214 |
* Use: |
| 215 |
<code> |
| 216 |
<?php if (function_exists('get_least_viewed_tag')): ?> |
| 217 |
<ul> |
| 218 |
<?php get_least_viewed_tag(); ?> |
| 219 |
</ul> |
| 220 |
<?php endif; ?> |
| 221 |
</code> |
| 222 |
* The first value you pass in is the tag id. |
| 223 |
* The second value you pass in is the post type that you want. If you want to get every post types, just use 'both'. It also supports PHP array: example `array('post', 'page')`. |
| 224 |
* The third value you pass in is the maximum number of post you want to get. |
| 225 |
* Default: get_least_viewed_tag(1, 'both', 10); |
| 226 |
|
| 227 |
= To Display Most Viewed Posts By Tag = |
| 228 |
* Use: |
| 229 |
<code> |
| 230 |
<?php if (function_exists('get_most_viewed_tag')): ?> |
| 231 |
<ul> |
| 232 |
<?php get_most_viewed_tag(); ?> |
| 233 |
</ul> |
| 234 |
<?php endif; ?> |
| 235 |
</code> |
| 236 |
* The first value you pass in is the tag id. |
| 237 |
* The second value you pass in is the post type that you want. If you want to get every post types, just use 'both'. It also supports PHP array: example `array('post', 'page')`. |
| 238 |
* The third value you pass in is the maximum number of post you want to get. |
| 239 |
* Default: get_most_viewed_tag(1, 'both', 10); |
| 240 |
|
| 241 |
= To Display Least Viewed Posts For A Category = |
| 242 |
* Use: |
| 243 |
<code> |
| 244 |
<?php if (function_exists('get_least_viewed_category')): ?> |
| 245 |
<ul> |
| 246 |
<?php get_least_viewed_category(); ?> |
| 247 |
</ul> |
| 248 |
<?php endif; ?> |
| 249 |
</code> |
| 250 |
* The first value you pass in is the category id. |
| 251 |
* The second value you pass in is the post type that you want. If you want to get every post types, just use 'both'. It also supports PHP array: example `array('post', 'page')`. |
| 252 |
* The third value you pass in is the maximum number of post you want to get. |
| 253 |
* Default: get_least_viewed_category(1, 'both', 10); |
| 254 |
|
| 255 |
= To Display Most Viewed Posts For A Category = |
| 256 |
* Use: |
| 257 |
<code> |
| 258 |
<?php if (function_exists('get_most_viewed_category')): ?> |
| 259 |
<ul> |
| 260 |
<?php get_most_viewed_category(); ?> |
| 261 |
</ul> |
| 262 |
<?php endif; ?> |
| 263 |
</code> |
| 264 |
* The first value you pass in is the category id. |
| 265 |
* The second value you pass in is the post type that you want. If you want to get every post types, just use 'both'. It also supports PHP array: example `array('post', 'page')`. |
| 266 |
* The third value you pass in is the maximum number of post you want to get. |
| 267 |
* Default: get_most_viewed_category(1, 'both', 10); |
| 268 |
|
| 269 |
= To Sort Most/Least Viewed Posts = |
| 270 |
* You can use: `<?php query_posts( array( 'meta_key' => 'views', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>` |
| 271 |
* Or pass in the variables to the URL: `http://yoursite.com/?v_sortby=views&v_orderby=desc` |
| 272 |
* You can replace DESC with ASC if you want the least viewed posts. |
| 273 |
|
| 274 |
= To Display Updating View Count With LiteSpeed Cache = |
| 275 |
1. Use: `<div id="postviews_lscwp"></div>` to replace `<?php if(function_exists('the_views')) { the_views(); } ?>`. |
| 276 |
* NOTE: The id can be changed, but the div id and the ajax function must match. |
| 277 |
2. Replace the ajax query in `wp-content/plugins/wp-postviews/postviews-cache.js` with |
| 278 |
|
| 279 |
` |
| 280 |
jQuery.ajax({ |
| 281 |
type:"GET", |
| 282 |
url:viewsCacheL10n.admin_ajax_url, |
| 283 |
data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews", |
| 284 |
cache:!1, |
| 285 |
success:function(data) { |
| 286 |
if(data) { |
| 287 |
jQuery('#postviews_lscwp').html(data+' views'); |
| 288 |
} |
| 289 |
} |
| 290 |
}); |
| 291 |
` |
| 292 |
|
| 293 |
3. Purge the cache to use the updated pages. |
| 294 |
|
| 295 |
|