I created styles for custom field, that is a radio button.
The style affects every .inside ul.acf-radio-list.radio.horizontal li label
but I want the style to work only on the Edit Post functionality.
How can I do that?
Add your styles to /your-theme/admin-edit-post.css
.inside ul.acf-radio-list.radio.horizontal li label {
/* styles... */
}
Then enqueue the styles by adding this to your theme's functions.php
:
function wpse250000_admin_styles( $hook ) {
// Bail if we're not on the post.php admin page
if ( 'post.php' !== $hook ) {
return;
}
// Ensure we're looking at a post. Add other post types to array if desired.
$post_type = get_post_type();
if ( ! $post_type || ! in_array( $post_type, [ 'post' ] ) ) {
return;
}
wp_enqueue_style( 'admin-edit-post-styles', get_template_directory_uri() . '/admin-edit-post.css' );
}
add_action( 'admin_enqueue_scripts', 'wpse250000_admin_styles' );