|
楼主 |
发表于 2021-6-15 08:24:50
|
显示全部楼层
去掉不要的 增加一些别的玩意
- //在后台文章列表增加N列数据
- add_filter( 'manage_posts_columns', 'ashuwp_customer_posts_columns' );
- function ashuwp_customer_posts_columns( $columns ) {
-
- $columns['class'] = '部位';
- $columns['band'] = '品牌';
- $columns['huoyuan'] = '货源';
- $columns['ranks'] = '排序';
- $columns['indexpic'] = '缩略图';
- unset($columns['tags']); //不显示标签
- unset($columns['comments']); //不显示评论
- unset($columns['author']); //不显示作者
- return $columns;
- }
-
- //输出排序、品牌等数据
- add_action('manage_posts_custom_column', 'ashuwp_customer_columns_value', 10, 2);
- function ashuwp_customer_columns_value($column, $post_id){
- if($column=='ranks'){
- $count = get_post_meta($post_id, 'rank', true);
- if($count==''){$count = 0;}
- echo $count;
- }
- if($column=='class'){
- $terms = get_the_terms($post->ID,'class');
- if($terms==''){echo '无';return;}
- foreach( $terms as $term ) {
- echo $term->name;
- }
- }
- if($column=='band'){
- $terms = get_the_terms($post->ID,'band');
- foreach( $terms as $term ) {
- echo $term->name;
- }
- }
- if($column=='huoyuan'){
- $terms = get_the_terms($post->ID,'huoyuan');
- foreach( $terms as $term ) {
- echo $term->name;
- }
- }
- if($column=='indexpic'){
- $image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail');
- echo '<img src="'.$image_url[0].'" />';
- }
- return;
- }
复制代码 |
|