[resolved] wp_enqueue_style not working (2 posts)

  1. Paul Kaiser
    Posted 4 years ago #

    I am trying to include some JavaScript and CSS with my plugin, and have it only show up when Pages or Posts are being Added or Edited in the admin side.

    No problem with the scripts being queuing up and showing up.
    The stylesheet, however, fails to ever show up.

    I am hooking into:

    add_action( "admin_print_scripts-post-new.php", array($this, 'cs_edit_scripts') );
    add_action( "admin_print_scripts-post.php", array($this, 'cs_edit_scripts') );

    The 'cs_edit_scripts' function is where I both enqueue the javascripts and the stylesheets. Again... the javascripts are working.
    I do this as follows: (the extra variable assignments at the top are just a result of me trying to figure things out over time...)

    // Get the path to our plugin directory, and then append the js/whatever.js
    $js_path = plugins_url('/js/ui.datepicker.min.js', __FILE__);
    $cs_path = plugins_url('/js/cs-datepicker.js', __FILE__);
    $style_path = plugins_url('/css/ui-lightness/jquery-ui-1.7.3.custom.css', __FILE__);
    wp_register_style('pkstyles', $style_path);
    wp_enqueue_script('jquery-ui-datepicker', $js_path, array('jquery','jquery-ui-core') );
    // enqueue our own script that makes datepicker work the way we want
    wp_enqueue_script('cs-datepicker', $cs_path, array('jquery','jquery-ui-core','jquery-ui-datepicker') );

    The javascripts are loaded and working... I get my datepicker... but the stylesheet never loads, so it's ugly.

    I have double and triple checked the path of the css file, etc.

    After two days of searching, I'm posting this here, and someone will probably point out that I missed a semicolon or something silly.

    Thanks for any help.

  2. Paul Kaiser
    Posted 4 years ago #

    There is a hook 'admin_print_styles' that needs used for stylesheets, separate from scripts, so the styles will show up in the right place.

Topic Closed

This topic has been closed to new replies.

About this Topic