如果你网站需要显示统计信息,可以在适宜的地方加入下方的代码。文章:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?> 篇页面:<?php $count_pages = w…
如果你网站需要显示统计信息,可以在适宜的地方加入下方的代码。
文章:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?> 篇页面:<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> 个草稿:<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?> 篇分类:<?php echo $count_categories = wp_count_terms('category'); ?> 个分类文章:<?php echo get_category(cat_ID)->count; ?>//cat_ID为你需要统计的分类标签:<?php echo $count_tags = wp_count_terms('post_tag'); ?> 个会员:<?php $users = $wpdb->get_var("Sref="https://xwenw.com/tag/e" target="_blank">ELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?> 个链接:<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?> 个评论:<?php $total_comments = get_comment_count(); echo $total_comments['approved'];?> 条浏览:<?php get_totalviews(); ?> 次//需要你安装PostViews插件,如果没装不要用运行:<?php echo floor((time()-strtotime("2010-04-02"))/86400);?>天更新:<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y年n月j日', strtotime($last[0]->MAX_m));echo $last; ?>
如果你要显示当前页面加载时间和查询数据库的请求次数。请在function加入这段
//显示页面查询次数、加载时间和内存占用 From mfbuoluo.comfunction performance( $visible = false ) { $stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory', get_num_queries(), timer_stop( 0, 3 ), memory_get_peak_usage() / 1024 / 1024 ); echo $visible ? $stat : "" ;}
在需要的页面调用下方这段
<?php timer_stop(1); ?> 秒内总共 <?php echo get_num_queries(); ?> 次查询
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)