以下是您想要的代码,除了“下载:Smartphone°Tablet°Desktop(原件)”。您可以在这个屏幕截图中看到http://prntscr.com/mmidnl
1. you can below code in functions.php file for visitors count. Reference: https://www.themexpert.com/blog/track-display-post-views-in-wordpress
function to display number of posts.
function getPostViews($postID){
$count_key = \'post_views_count\';
$count = get_post_meta($postID, $count_key, true);
if($count==\'\'){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, \'0\');
return "0 Visitor";
}
return $count.\' Visitors\';
}
function to count views.
function setPostViews($postID) {
$count_key = \'post_views_count\';
$count = get_post_meta($postID, $count_key, true);
if($count==\'\'){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, \'0\');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
Remove issues with prefetching adding extra views
remove_action( \'wp_head\', \'adjacent_posts_rel_link_wp_head\', 10, 0);
一
remove_action( \'wp_head\', \'adjacent_posts_rel_link_wp_head\', 10, 0);
<div class="data">
<div>Detail Of <?php the_title(); ?> Posted : <?php the_time(\'F j, Y\'); ?> At <?php the_time(\'g:i a\'); ?></div>
<div>Author : <?php the_author(); ?></div>
<div>Category : <?php the_category( \', \' ); ?></div>
<div><?php the_tags( \'Tags: \'); ?> </div>
<div><?php setPostViews(get_the_ID()); ?>Viewed : <?php echo getPostViews(get_the_ID()); ?></div>
<div><?php $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" ); $img_s = get_headers($image_data[0], 1); $img_size_wd = $img_s["Content-Length"]/1024; $img_size_kb = number_format((float)$img_size_wd, 2, \'.\', \'\'); ?>File Size : <?php echo $img_size_kb; ?> KB</div>
<div><?php $img_id = get_post_thumbnail_id($post->ID); $type = get_post_mime_type( $img_id ); ?>File Type : <?php echo $type; ?></div>
<div><?php $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" ); ?> Resolution : <?php echo $image_data[1]; ?> x <?php echo $image_data[2]; ?> Pixel</div>
<div><?php $img_id = get_post_thumbnail_id($post->ID); ?>Download Many Resolution: <?php echo \'<a href="\'. get_attachment_link($img_id) . \'">Click Here</a>\'; ?></div>
</div>