开发者 | straker503 |
---|---|
更新时间 | 2014年8月6日 14:08 |
捐献地址: | 去捐款 |
PHP版本: | 3.5 及以上 |
WordPress版本: | 3.7.1 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
jetpack-post-views.php
to the /wp-content/plugins/
directory<?php echo get_post_meta( $post->ID, 'jetpack-post-views', true ); ?>
To display views for a day, week, month, or year, add the appropriate code:
<?php echo get_post_meta( $post->ID, 'jetpack-post-views-Day', true ); ?>
<?php echo get_post_meta( $post->ID, 'jetpack-post-views-Week', true ); ?>
<?php echo get_post_meta( $post->ID, 'jetpack-post-views-Month', true ); ?>
<?php echo get_post_meta( $post->ID, 'jetpack-post-views-Year', true ); ?>
Stats are updated hourly only if the plugin is active.
There are many factors that could go wrong that would prevent a post from updating. Before you submit a support ticket, please ensure that:
Use the function 'JPV_display_top_posts()'
Usage
<?php if ( function_exists('JPV_display_top_posts') ) { JPV_display_top_posts( $args ); } ?>
Default Usage
<?php $args = array( 'days' => '-1', 'limit' => '5', 'exclude' => '', 'excludeCustomPostTypes' => false, 'displayViews' => false ); ?>
Parameters
days - (string) The number of days of the desired time frame. '-1' means unlimited.
limit - (string) The number of posts to display. '-1' means unlimited. If days is -1, then limit is capped at 500.
exclude - (string) A comma-separated list of Post IDs to be excluded from displaying.
excludeCustomPostTypes - (boolean) Excludes custom post types from displaying.
displayViews - (boolean) Displays the post views.
NOTE This function only works if the function stats_get_csv()
exists. If this function is not working probably, it is probably due to the stats_get_csv()
function not returning the needed results.
Use the shortcode '[jpv]' The shotcode uses the same parameters as the 'JPV_display_top_posts()' function
JPV_display_top_posts()
function to display top posts in a template