首先,您需要声明/注册新列:
add_filter( \'manage_tour_posts_columns\', \'cyb_add_new_columns\' );
function cyb_add_new_columns() {
$columns[\'price\'] = __(\'Price column title\', \'cyb-textdomain\' );
$columns[\'test\'] = __(\'Test column title\', \'cyb-textdomain\' );
return $columns;
}
然后,您可以打印每篇文章的列内容:
add_action(\'manage_tour_posts_custom_column\', \'tour_price_col\', 10 ,2);
function tour_price_col( $column, $post_id){
switch ( $column ) {
case \'price\':
echo get_post_meta( $post_id, \'tour-price\', true );
break;
case \'test\':
echo "salam";
break;
}
}