0

I'm using the following to enqueu an admin style:

wp_enqueue_style('pk-admin-css', PULUGIN_URL . 'css/admin.css');

This outputs the style file appended with the ?=ver parameter which results in the file loading with no content.

I can fix this by removing that parameter like so:

wp_enqueue_style('pk-admin-css', PULUGIN_URL . 'css/admin.css', array(), null)

basically give it the version a nul value which removes it. My question though is.. The front-end style loads fine with that version number but why my admin style is not? Can someone explain this for me?

Thank you.

  • This is strange. Could you please provide a screenshot of your browser's console? – Jack Johansson Nov 19 '17 at 12:39
0

It has nothing to do with version. First of all you have a typo in constant name: PULUGIN_URL. Even if you change it to PLUGIN_URL, it will not work, because such constant does not exists. When you do it from within plugin, use proper function. In your case it should be: plugin_dir_url(__FILE__). Your code should be:

function wpse_enqueue_style() {
    wp_enqueue_style('pk-admin-css', plugin_dir_url(__FILE__) . 'css/admin.css');
}
add_action( 'admin_enqueue_scripts', 'wpse_enqueue_style' );
0
// load css into the admin page use admin_enqueue_scripts or admin_print_styles

function mytheme_enqueue_options_style() {
    wp_enqueue_style( 'mytheme-options-style', get_template_directory_uri() . '/css/admin.css' ); 
}
add_action( 'admin_enqueue_scripts', 'mytheme_enqueue_options_style' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.