分类
WordPress代码片断

给wordpress后台添加分类列表显示ID功能


function ssid_column($cols) {
	$cols['ssid'] = 'ID';// wodepress.org
	return $cols;
}
 
function ssid_value($column_name, $id) {
	if ($column_name == 'ssid')
		echo $id;
}
 
function ssid_return_value($value, $column_name, $id) {
	if ($column_name == 'ssid')
		$value = $id;
	return $value;
}
 
 
function ssid_css() {
?>
<style type="text/css">
	#ssid { width: 50px; }
</style>
<?php	
}
 

function ssid_add() {
	add_action('admin_head', 'ssid_css');
 

 
	foreach ( get_taxonomies() as $taxonomy ) {
		add_action("manage_edit-${taxonomy}_columns", 'ssid_column');	// wodepress.org		
		add_filter("manage_${taxonomy}_custom_column", 'ssid_return_value', 10, 3);
	}

}
 
add_action('admin_init', 'ssid_add');