WP实现建站天数、文章总数、最后更新时间功能。
本文最后更新于 3634 天前,其中的信息可能已经有所发展或是发生改变。
步骤:
  1. 登录博客后台 -> 选择外观选项的编辑项。
  2. 选择index.php或其它你想修改的文件,选择合适位置进行函数调用。

然后回到首页刷新就OK了!

以下是调用代码:

文章:<?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 $count_tags = wp_count_terms('post_tag'); ?> 个
会员:<?php $users = $wpdb->get_var("SELECT 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(true, true, true); ?> 次
运行:<?php echo floor((time()-strtotime("2013-10-01"))/86400);?>天
//请将 2013-10-01 修改为您的建站日期
更新:<?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; ?>

 

评论

  1. Image
    Windows Chrome 52.0.2743.116
    10 年前
    2016-9-04 0:19:04

    提交失败:评论必须包含中文(Chinese),请再次尝试!

  2. Image
    Windows Chrome 53.0.2785.89
    10 年前
    2016-9-05 9:18:08

    被EMlog抛弃的娃啊

    • Image
      博主
      神父
      Windows Chrome 52.0.2743.116
      10 年前
      2016-9-05 11:12:11

      是我抛弃了Emlog,此处耿直的笑

  3. Image
    Windows Chrome 45.0.2454.101
    10 年前
    2016-9-05 14:19:12

    其实你可以把emlog的数据转过来的。

    • Image
      博主
      大雄
      iPhone Safari 5.1
      10 年前
      2016-9-07 9:16:59

      其实也没什么吧 放到景安哪里也不错

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇