![]() ![]() $media can specify which type of media to load this stylesheet in, such as ‘all’, ‘screen’, ‘print’ or ‘handheld.’.If this is set, this stylesheet will not be loaded unless its dependent stylesheet is loaded first. $deps refers to whether or not this stylesheet is dependent on another stylesheet.$handle is simply the name of the stylesheet.The basic function for enqueuing a style is: wp_enqueue_style( $handle, $src, $deps, $ver, $media ) This will look for a stylesheet named “style” and load it. To enqueue style.css: wp_enqueue_style( 'style', get_stylesheet_uri() ) In order to load your main stylesheet, you can enqueue it in functions.php Rather then loading the stylesheet in your header.php file, you should load it in using wp_enqueue_style. For this reason, the style.css file is required in every theme. A stylesheet is also the file where information about your theme is stored. Your CSS stylesheets are used to customize the presentation of your theme. Enqueue the script or style using wp_enqueue_script(), wp_enqueue_style(), or wp_enqueue_block_style.Before adding your own JavaScript, check to see if you can make use of an included library. Tip: WordPress includes a number of JavaScript files as part of the software package, including commonly used libraries such as jQuery. The style.css file is required in all themes, but it may be necessary to add other files to extend the functionality of your theme. ![]() The proper way to add scripts and styles to your theme is to enqueue them in the functions.php files. When enqueuing a script or stylesheet, WordPress creates a handle and path to find your file and any dependencies it may have (like jQuery) and then you will use a hook that will insert your scripts and stylesheets. Essentially, you will create a function that will enqueue all of your scripts and styles. This will ensure the site remains efficient and that there are no incompatibility issues.Īdding scripts and styles to WordPress is a fairly simple process. So that everything works harmoniously, it’s important that theme and plugins load scripts and stylesheets using the standard WordPress method. However, remember that a WordPress website will not just have your theme active, it will also be using many different plugins. When you’re creating your theme, you may want to create additional stylesheets or JavaScript files. Default Scripts Included and Registered by WordPress.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |