So you should always use wp_enqueue_style in your themes. Note that wp_enqueue_style function has priority over wp_register_style since it is hooked to wpHead hook. You can check wpDashboards registered stylesheets list by this curl command: curl wpdashboardList ![]() Wp_register_style(“myStyle”, $handle) // $handle – pointer to registered handle in wprockets wprocketsRegisterStyle(“myHandle”, $filePath) // $filePath – absolute path of your file wpHeaderCss($handle,$srcFile) If you need only one of them and don’t want to include whole wproclie class for it, do this: ” type=”text/css”/> Learn more about wp_enque_style ” type=”text/css” media=”screen”> wp_enque_style with wp rocket plugin Note: wp_enqueue_script, wp_register_script and wp_print_scripts have almost the same parameters as wp_enqueue style except src should be a path to javascript file instead of a CSS stylesheet. ![]() $deps – array of dependencies listed here: $handle – pointer to registered style handle in wprockets (you will need this only if you don’t pass it as argument) For other cases you should use wp_register_style function.įor all the wp_enqueue_style examples you can find at codex: wp_enqueue_style($handle, $src, $deps) So, wp_enqueue_style will work only if the stylesheet is inside wp-content directory or inside wp-includes directory. So you should always include all the stylesheets inside this file for your theme.īut wp_enqueue_style will load stylesheets stored outside of wp-content directory into section like wp-content/themes/themeName/header.php wp_enqueue_style wp-content/themes/themeName/css/custom.css ![]() WordPress loads stylesheets in wp-content/themes/themeName/style.css (or wp-includes/css if style.css doesn’t exist). Once you know how to wp_enqueue_style, it is quite easy to do in your theme or in plugins. Many WordPress plugin and theme developers use wp_enqueue_style function to register stylesheets with wp_head hook. In this article, we will discuss how to properly use wp_enqueue_style in the latest version of WordPress template files.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |