Standing on the Shoulder of Linus
現在地: / Home / 2010 / 10月 / 16 / Number of Custom Post Type on your Dashboard
印刷 メール ショートリンク

Number of Custom Post Type on your Dashboard

投稿者 mizuno 作成日 2010年10月16日 in myplugin

You can use Custom Post Type in WordPress 3.0. By default, Number of Custom Post Type is now shown in “Right Now” on your Dashboard. You can see how many Custom Post Type you posted, by adding the following code on your functions.php.

Please fill in the label of the custom post type. For example, you are using an “event” post type, $custom_post_type = 'event';.

function custom_post_dashboard() {
    $custom_post_type = 'event'; // Fill in the label of CPT
    global $wp_post_types;
    $num_post_type = wp_count_posts( $custom_post_type );
    $num = number_format_i18n($num_post_type->publish);
    $text = _n( $wp_post_types[$custom_post_type]->labels->singular_name, $wp_post_types[$custom_post_type]->labels->name, $num_post_type->publish );
    $capability = $wp_post_types[$custom_post_type]->cap->edit_posts;

    if (current_user_can($capability)) {
        $num = "<a href='edit.php?post_type=" . $custom_post_type . "'>$num</a>";
        $text = "<a href='edit.php?post_type=" . $custom_post_type . "'>$text</a>";
    }

    echo '<tr>';
    echo '<td class="first b b_' . $custom_post_type . '">' . $num . '</td>';
    echo '<td class="t ' . $custom_post_type . '">' . $text . '</td>';
    echo '</tr>';
}
add_action('right_now_content_table_end', 'custom_post_dashboard');

Here, right_now_content_table_end is a name of action hook.

The picture is a dashboard with an additional row “イベント” (Japanese word for “event”). If users are allowed to edit the posts of this custom post type, they can click the link and go to edit.php.

シェア: Mixx Delicious Digg Facebook Twitter
admin area
返信をキャンセル
← 前へ 次へ →

良く見られている記事

  • キンドル本を印刷する(PDFに変換する)方法
  • WordPress の月別アーカイブ
  • Home
  • 名古屋駅から国際センターまでの道のり
  • featured image アイキャッチ画像

アーカイブ

最近の投稿

  • AGPL ライセンスについて
  • WordPress の更新にプラグインが追従しなかった場合の対処方法まとめ
  • Novius OS で A/B テスト
  • FuelPHP 勉強会 東海 vol.4 開催しました
  • 書評 「アメブロからWordPressへの移行方法」
  • Novius OS 言語/文字エンコーディング関連の問題
  • 言い値書店 アクセス解析と販売データ 2013年4月号
  • KDPノ全テを読んだ
  • Novius OS フォームで日本の住所を扱う
  • Novius OS Chiba リリース
  • 管理者紹介
  • オープンソースのメリットデメリット
  • wordbench
  • myplugin
  • Contact

Copyright © 2008-2013 Standing on the Shoulder of Linus. Powered by WordPress

ブログ、CMS構築はPHPでWEB作成