I wrote a small plugin and i want to add some css design my plugin meta boxes in the WordPress system. All the scripts of adding a css file to WordPress plugin that I found are referring to including a css file in the plugin output page on the website itself. - wp_enqueue_scripts
the solution i created is to use this piece of code in my plugin page:
echo '<style type="text/css">';
include( '/css/style.css' );
echo '</style>';
But if feels to me like an unprofessional solution so I wanted to ask if anyone knows a better solution
You can use wp_enqueue_style()
yourself, with plugins_url()
:
function my_styles(){
$css_path = plugins_url('/css/style.css', __FILE__);
wp_enqueue_style('my_stylesheet', $css_path);
}
add_action( 'admin_init', 'my_styles' );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.