0

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

1 Answer 1

1

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' );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.