Thứ Năm, 1 tháng 2, 2018

Short code thống kê website wp

///////////////////////////////////////////
/****** SHORTCODE THONG KE WEBSITE ******/
/////////////////////////////////////////
function statistics_site($atts){
ob_start(); ?>
   
    <div class="md_statistics_site">
    <div class="label_md_statistics_site">
    <span>Thống kê website</span>
    </div>
    <div class="view_all_site row">
    <div class="label_view_all_site large-8"><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2018/01/icon-view.png"> Page View</div>
    <div class="number_view_all_site large-4"><span><?php echo viewsite(get_the_ID()); ?></span></div>
    </div>

    <div class="tk_view_on_site row">
    <div class="label_view_all_site large-8"><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2018/01/user-onl.png"> Đang online</div>
    <div class="number_view_all_site large-4"><span><script id="_wauio7">var _wau = _wau || []; _wau.push(["small", "rtv31kda92", "io7"]);</script><script async src="//waust.at/small.js"></script></span></div>
    </div>

    <?php
$count_posts = wp_count_posts('product');
if ( $count_posts ) {
$total_posts = $count_posts->publish;
}
$total_posts;
?>
    <div class="total_number_post row">
    <div class="label_view_all_site large-8"><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2018/01/post.png"> Tổng số bài viết</div>
    <div class="number_view_all_site large-4"><span><?php echo $total_posts; ?></span></div>
    </div>

    <?php
    $comments_count = wp_count_comments();
    $total_comment_site = $comments_count->total_comments;
    ?>
    <div class="total_comment_site row">
    <div class="label_view_all_site large-8"><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2018/01/icon-comment.png"> Tổng lượt Comments</div>
    <div class="number_view_all_site large-4"><span><?php echo $total_comment_site; ?></span></div>
    </div>
   
   
    </div>

   
    <?php return ob_get_clean();
}
add_shortcode('namhp_statistics_site', 'statistics_site');

Không có nhận xét nào:

Đăng nhận xét