# WP-PostViews
Contributors: GamerZ
Donate link: https://lesterchan.net/site/donation/
Tags: views, hits, counter, postviews
Requires at least: 4.0
Tested up to: 5.3
Stable tag: 1.76.1
Enables you to display how many times a post/page had been viewed.
## Description
### Usage
1. Open `wp-content/themes/<YOUR THEME NAME>/index.php`
2. You may place it in archive.php, single.php, post.php or page.php also.
3. Find: `<?php while (have_posts()) : the_post(); ?>`
4. Add Anywhere Below It (The Place You Want The Views To Show): `<?php if(function_exists('the_views')) { the_views(); } ?>`
5. Or you can use the shortcode `[views]` or `[views id="1"]` (where 1 is the post ID) in a post
6. Go to `WP-Admin -> Settings -> PostViews` to configure the plugin.
### Build Status
[![Build Status](https://travis-ci.org/lesterchan/wp-postviews.svg?branch=master)](https://travis-ci.org/lesterchan/wp-postviews)
### Development
[https://github.com/lesterchan/wp-postviews/](https://github.com/lesterchan/wp-postviews/ "https://github.com/lesterchan/wp-postviews/")
### Translations
[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/")
### Credits
* Plugin icon by [Iconmoon](http://www.icomoon.io) from [Flaticon](http://www.flaticon.com)
### Donations
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.
## Changelog
## Version 1.76.1
* NEW: Add Post Author in views template
* NEW: Bump for WordPress 5.3
### Version 1.76
* NEW: Added postviews_should_count filter
* FIXED: Change to (int) from intval() and use sanitize_key() with it.
### Version 1.75
* NEW: Use WP_Query() for most/least viewed posts
### Version 1.74
* NEW: Bump WordPress 4.7
* 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
### Version 1.73
* FIXED: In preview mode, don't count views
### Version 1.72
* NEW: Add %POST_THUMBNAIL% to template variables
### Version 1.71
* FIXED: Notices in Widget Constructor for WordPress 4.3
### Version 1.70
* FIXED: Integration with WP-Stats
### Version 1.69
* NEW: Shortcode `[views]` or [views id="POST_ID"]` to embed view count into post
* NEW: Added template variable `%VIEW_COUNT_ROUNDED%` to support rounded view count like 10.1k or 11.2M
### Version 1.68
* NEW: Added action hook 'postviews_increment_views' and 'postviews_increment_views_ajax'
* NEW: Allow custom post type to be chosen under the widget
### Version 1.67
* NEW: Allow user to not use AJAX to update the views even though WP_CACHE is true
### Version 1.66
* NEW: Supports MultiSite Network Activation
* NEW: Add %POST_DATE% and %POST_TIME% to template variables
* NEW: Add China isearch engines bots
* NEW: Ability to pass in an array of post types for get_most/least_*() functions. Props Leo Plaw.
* FIXED: Moved uninstall to uninstall.php and hence fix missing nonce. Props Julio Potier.
* FIXED: Notices and better way to get views from meta. Props daankortenbach.
* FIXED: No longer needing add_post_meta() if update_post_meta() fails.
### Version 1.65 (02-06-2013)
* FIXED: Views not showing in WP-Admin if "Display Options" is not set to "Display to everyone"
## Upgrade Notice
N/A
## Screenshots
1. PostViews
2. Admin - PostViews Options
## Frequently Asked Questions
### How To View Stats With Widgets?
* Go to `WP-Admin -> Appearance -> Widgets`
* The widget name is Views.
### To Display Least Viewed Posts
~~~
<?php if (function_exists('get_least_viewed')): ?>
<ul>
<?php get_least_viewed(); ?>
</ul>
<?php endif; ?>
~~~
* 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')`.
* The second value you pass in is the maximum number of post you want to get.
* Default: get_least_viewed('both', 10);
### To Display Most Viewed Posts
~~~
<?php if (function_exists('get_most_viewed')): ?>
<ul>
<?php get_most_viewed(); ?>
</ul>
<?php endif; ?>
~~~
* 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')`.
* The second value you pass in is the maximum number of post you want to get.
* Default: get_most_viewed('both', 10);
### To Display Least Viewed Posts By Tag
~~~
<?php if (function_exists('get_least_viewed_tag')): ?>
<ul>
<?php get_least_viewed_tag(); ?>
</ul>
<?php endif; ?>
~~~
* The first value you pass in is the tag id.
* 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')`.
* The third value you pass in is the maximum number of post you want to get.
* Default: get_least_viewed_tag(1, 'both', 10);
### To Display Most Viewed Posts By Tag
~~~
<?php if (function_exists('get_most_viewed_tag')): ?>
<ul>
<?php get_most_viewed_tag(); ?>
</ul>
<?php endif; ?>
~~~
* The first value you pass in is the tag id.
* 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')`.
* The third value you pass in is the maximum number of post you want to get.
* Default: get_most_viewed_tag(1, 'both', 10);
### To Display Least Viewed Posts For A Category
~~~
<?php if (function_exists('get_least_viewed_category')): ?>
<ul>
<?php get_least_viewed_category(); ?>
</ul>
<?php endif; ?>
~~~
* The first value you pass in is the category id.
* 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')`.
* The third value you pass in is the maximum number of post you want to get.
* Default: get_least_viewed_category(1, 'both', 10);
### To Display Most Viewed Posts For A Category
~~~
<?php if (function_exists('get_most_viewed_category')): ?>
<ul>
<?php get_most_viewed_category(); ?>
</ul>
<?php endif; ?>
~~~
* The first value you pass in is the category id.
* 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')`.
* The third value you pass in is the maximum number of post you want to get.
* Default: get_most_viewed_category(1, 'both', 10);
### To Sort Most/Least Viewed Posts
* You can use: `<?php query_posts( array( 'meta_key' => 'views', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>`
* Or pass in the variables to the URL: `http://yoursite.com/?v_sortby=views&v_orderby=desc`
* You can replace DESC with ASC if you want the least viewed posts.
### To Display Updating View Count With LiteSpeed Cache
Use: `<div id="postviews_lscwp"></div>` to replace `<?php if(function_exists('the_views')) { the_views(); } ?>`.
NOTE: The id can be changed, but the div id and the ajax function must match.
Replace the ajax query in `wp-content/plugins/wp-postviews/postviews-cache.js` with
~~~
jQuery.ajax({
type:"GET",
url:viewsCacheL10n.admin_ajax_url,
data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
cache:!1,
success:function(data) {
if(data) {
jQuery('#postviews_lscwp').html(data+' views');
}
}
});
~~~
Purge the cache to use the updated pages.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
主题介绍 不知道还有多少人记得KuImg这个主题呢?细算一下,自第1个版本发布开始已经有7年了! 啊!这~~ 时间过得真快…… 网上也有好多人拿着我的免费主题去出售的,请大家擦亮眼睛不要被骗了,因为KuImg主题从来没有收费过,一直是免费的! 免费的 !! 免费的 !!!(重要的事说3遍)。 由于v6.0版本是一边使用一边完善,所以效率较低迟迟没有发布。在经历了N个日夜的功能完善、bug修复后,今天终于迎来了v6.0版本的正式发布;还是一如既往,本主题支持发布文章、图集、视频,可以说是全能主题。 下面简单说一下这次版本更新都有些啥功能吧,只挑重点的说: 新增 多集电视连续剧功能(本版本最重要的功能,并且支持断点续播); 新增 会员模式,支持设置会员专享内容(分了VIP和SVIP两种权限,还支持非会员试看功能哦); 重构 短视频代码,内置JWPlayer 8.2.10,同学们可以根据自身情况进行升级; 重构 相册模式代码,相对上一个版本更美观,移动端也更友好; 重构 移动端页面布局,相对上一版本更美观更大气; 想列这么几个吧,想起来再增加,没有提到的功能各位同学使用过程中慢慢发现吧
资源推荐
资源详情
资源评论
收起资源包目录
KuImg_v6.0:wordpress多用途CMS主题正式版发布 (466个子文件)
bootstrap.min.css 107KB
main.css 92KB
wap-work.css 40KB
iconfont.css 27KB
iconfont.css 27KB
font-awesome.css 23KB
swiper.min.css 19KB
main.css 11KB
player.css 10KB
player.css 9KB
picture.css 9KB
picture.css 8KB
base.css 8KB
piccontext.css 7KB
piccontext.css 7KB
style.css 6KB
style.css 6KB
style.css 6KB
show.css 4KB
admin.css 4KB
wp_framework.css 3KB
jumbotron-narrow.css 3KB
metabox_css.css 2KB
main.css 2KB
laypage.css 1KB
sidemenu.css 1KB
guide-septAct.css 947B
guide-septAct.css 842B
sortable.min.css 311B
jquery.flex-images.css 229B
style.css 83B
style.css 75B
arr_right.cur 2KB
arr_left.cur 2KB
iconfont.eot 29KB
iconfont.eot 29KB
spinner-300.gif 20KB
spinner-250.gif 20KB
spinner-230.gif 19KB
spinner-320.gif 18KB
spinner-181.gif 17KB
spinner-291.gif 17KB
spinner-205.gif 16KB
spinner.gif 12KB
spinner.gif 12KB
tis.gif 8KB
spinner-80.gif 8KB
icon-view_4b787901.gif 4KB
spinner1.gif 3KB
loading.gif 2KB
loading.gif 2KB
hot-004.gif 915B
tophot.gif 558B
grey.gif 49B
t.gif 49B
grey.gif 49B
inputbg.gif 0B
jiexibg.jpg 381KB
26e86040b5f405b.jpg 256KB
screenshot.jpg 128KB
bg.jpg 94KB
screenshot.jpg 75KB
404.jpg 53KB
vip.jpg 42KB
vip.jpg 42KB
pximg-app.jpg 41KB
index-ico.jpg 39KB
404.jpg 18KB
avatar-default.jpg 17KB
avatar-default.jpg 17KB
zz_logo.jpg 13KB
dz.jpg 13KB
zzlogo.jpg 12KB
kh.jpg 11KB
zz.jpg 11KB
null.jpg 11KB
null.jpg 11KB
xj.jpg 10KB
jq.jpg 8KB
rand.jpg 8KB
line_bg01_l.jpg 8KB
default.jpg 3KB
camTitleBg.jpg 1KB
photo.jpg 941B
left1.jpg 660B
right1.jpg 659B
list_1.jpg 648B
gaoqing_1.jpg 613B
jiantou1.jpg 478B
list.jpg 472B
gaoqing.jpg 452B
close.jpg 408B
close.jpg 408B
line_bg01.jpg 304B
provider.hlsjs.js 409KB
provider.hlsjs.js 409KB
provider.shaka.js 371KB
provider.shaka.js 371KB
jwplayer.core.controls.polyfills.html5.js 347KB
jwplayer.core.controls.polyfills.html5.js 347KB
共 466 条
- 1
- 2
- 3
- 4
- 5
资源评论
地理探险家
- 粉丝: 986
- 资源: 5416
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功