0

I am trying to load custom css specifically relevant to the plugin. The js is working perfectly fine, but the css just refuses to get loaded in. Here is the code:

function admin_plugin_scripts(){

  wp_enqueue_style('arena', plugin_dir_url(__FILE__) . 'css/arena.css',
                    array(), filemtime( WP_PLUGIN_DIR . 
                   '/PluginName/css/arena.css'), true  );

  wp_enqueue_script('admin', plugin_dir_url(__FILE__) . 'js/admin.js',
                     array('jquery'),
                     filemtime( WP_PLUGIN_DIR . 
                     '/PluginName/js/admin.js' ), true); 

  wp_localize_script( 'admin', 'ajaxobj',
                      array('ajax_url' =>admin_url('admin-ajax.php')));
}
add_action('admin_enqueue_scripts', 'admin_plugin_scripts');

Thanks in advance for any help offered!

2

The function wp_enqueue_style last argument is the $media and you set it to true so its mean you are doing

<link rel='stylesheet' ... media='1' />

$media (string) (Optional) The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.

Default value: 'all'

So you should or remove the last argument so it will be the default all or just set some other media type.

wp_enqueue_style('arena', plugin_dir_url(__FILE__) . 'css/arena.css',
                array(), filemtime( WP_PLUGIN_DIR . 
               '/PluginName/css/arena.css') );
  • Ah, thanks! yeah I should have double checked that parameter ... 0_0 – Chad Denaux Jul 2 '18 at 18:01

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.