此代码运行得非常好:
function custom_columns( $columns ) {
$columns = array(
\'cb\' => \'<input type="checkbox" />\',
\'title\' => \'Title\',
\'featured_image\' => \'Image\',
\'categories\' => \'Categories\',
\'amazon_url\' => \'Amazon Link\',
\'comments\' => \'<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>\',
\'date\' => \'Date\'
);
return $columns;
}
add_filter(\'manage_posts_columns\' , \'custom_columns\');
function custom_columns_data( $column, $post_id ) {
switch ( $column ) {
case \'featured_image\':
the_post_thumbnail( \'thumbnail\' );
break;
case \'amazon_url\' :
echo get_field( \'product_url\', $post_id );
break;
}
}
add_action( \'manage_posts_custom_column\' , \'custom_columns_data\', 10, 2 );
我意识到有一个拼写错误
case \'anazon_url\' :
(不过我在问题中更新了它)
是的case \'anazon_url\' :
即使在修复了打字错误后,它仍然不起作用,但后来我清除了缓存并再次尝试,它仍然起作用!
所以我把代码留在这里,如果有人想在管理列中显示ACF数据,请点击这里!