简体   繁体   中英

wp_enqueue_style Not working after upgrade

Can't get the stylesheet to show in end results.

Sorry, the stack overflow does not work.

The function runs. Echoing after Main.min.css works, but the script is not showing. Im not sure why. Everything I try does not work.

wp_enqueue_style('style.css', get_stylesheet_directory_uri() . '/style.css', array(), NAKED_VERSION, FALSE);
//wp_enqueue_style('bootstrap.min.css', get_stylesheet_directory_uri() . '/stylesheets/bootstrap.min.css', array(), NAKED_VERSION, FALSE);
wp_enqueue_style('slick.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css', array(''), NAKED_VERSION, FALSE);
wp_enqueue_style('slick-theme.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css', array('slick.min.css'), NAKED_VERSION, FALSE);
wp_enqueue_style('main-site.min.css', get_template_directory_uri() . '/stylesheets/main.min.css', array('slick-theme.min.css'), NAKED_VERSION, FALSE);

I want main.min.css at the path specified to show up as designed. Wordpress 5 broke this. The site no longer shows correctly.

Edit (added): How do I get my site to work as it was before the upgrade, given that the above statements clearly indicate the problem and that the display is not correct?

Resolution Found (edit): I removed the dependency string from the array and found that caused it to load. I then simplified the dependency string (found above) to not include the extensions. I also removed the '' from the array in the 'slick.min.css'. This caused it to resolve.

Are you sure that you added wp_head() and wp_footer() in header.php and footer.php? Verify that the wp_enqueue_style should work then.

Yes, i can confirm. I had the same problem after an update from 5.0.0 to 5.0.2.

Removing the dependencies did fix the issue for me also.

before:

wp_enqueue_style(
  'nuk.editor',
  plugins_url($editorStylePath, __FILE__),
  [  'wp-blocks' ],
  filemtime( plugin_dir_path( __FILE__ ) . $editorStylePath )
);

after:

wp_enqueue_style(
  'nuk.editor',
  plugins_url($editorStylePath, __FILE__),
  [],
  filemtime( plugin_dir_path( __FILE__ ) . $editorStylePath )
);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM