您可能想使用wp_enqueue_scripts
行动,并在其中,而不是custom_field
您将使用get_post_meta
, 像这样:
function wpse217823_enqueue_per_custom_field(){
global $post;
$layout = get_post_meta( $post->ID, \'layout\', true );
if( $layout == ... ){
wp_enqueue_style( \'my-custom-style-here\' );
}
}
add_action( \'wp_enqueue_scripts\', \'wpse217823_enqueue_per_custom_field\' );