/* 投稿一覧にスラッグ追加 */
function add_posts_columns_slug($columns) {
$columns['slug'] = 'スラッグ';
return $columns;
}
function add_posts_columns_slug_row($column_name, $post_id) {
if( $column_name == 'slug' ) {
$slug = get_post($post_id) -> post_name;
echo esc_attr($slug);
}
}
add_filter( 'manage_posts_columns', 'add_posts_columns_slug' );
add_action( 'manage_posts_custom_column', 'add_posts_columns_slug_row', 10, 2 );
/* 固定ページ一覧にスラッグ追加 */
function add_page_columns_slug($columns) {
$columns['slug'] = 'スラッグ';
return $columns;
}
function add_page_column_slug_row($column_name, $post_id) {
if( $column_name == 'slug' ) {
$slug = get_post($post_id) -> post_name;
echo esc_attr($slug);
}
}
add_filter( 'manage_pages_columns', 'add_page_columns_slug');
add_action( 'manage_pages_custom_column', 'add_page_column_slug_row', 10, 2);