LoginSignup
8
11

More than 5 years have passed since last update.

Wordpress で管理画面にカテゴリIDを表示

Posted at

検索してみたら『URLのパラメータを調べろ』ばっかりだったのでメモ。

functions.php に

<?php
function add_category_columns($columns)
{
    $index = 1; // 追加位置

    return array_merge(
        array_slice($columns, 0, $index),
        array('id' => 'ID'),
        array_slice($columns, $index)
    );
}
add_filter('manage_edit-category_columns', 'add_category_columns');

function add_category_custom_fields($deprecated, $column_name, $term_id)
{
    if ($column_name == 'id') {
        echo $term_id;
    }
}
add_action('manage_category_custom_column', 'add_category_custom_fields', 10, 3);

て書いておくと編集画面がこんな感じになります。

categories.png

他の場所に出す時はフィルタ/アクション名を調べて追記すれば良し。

8
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
11