The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme

wp_enqueue_scripts Action Hook: WordPress provides various names (or place holders) that can be used to inject callback functions within WordPress core’s execution lifecycle. These are called action and filter hooks. wp_enqueue_scripts is a WordPress action hook. Note: It’s not wp_enqueue_script, it’s plural: wp_enqueue_scripts. With this hook, we add script or style on the correct time … Read more

How to add extra attribute to stylesheet link?

We can use style_loader_tag filter to filter the link that is being output. Here is the filter: $tag = apply_filters( ‘style_loader_tag’, “<link rel=”$rel” id=’$handle-css’ $title href=”https://wordpress.stackexchange.com/questions/231597/$href” type=”text/css” media=”$media” />\n”, $handle, $href, $media); Here the link $handle for which you want to add attribute is font-awesome so if the handle, so you can replace font-awesome-css with … Read more

Give priority to child theme stylesheet

Your child theme’s stylesheet will usually be loaded automatically. If it is not, you will need to enqueue it as well. Setting ‘parent-style’ as a dependency will ensure that the child theme stylesheet loads after it. /** * Enqueue theme styles (parent first, child second) * */ function wpse218610_theme_styles() { $parent_style=”parent-style”; wp_enqueue_style( $parent_style, get_template_directory_uri() . … Read more

Why I can’t add a CSS style in this WordPress theme?

You are using plugins_url – therefore pointing to completly different directory than your current theme. If you are just trying to enqueue a theme style do it like this: function load_theme_styles() { wp_enqueue_style(‘main-css’, get_template_directory_uri() . ‘/style.css’, array(), ‘1.0’, ‘all’); } add_action(‘wp_enqueue_scripts’, ‘load_theme_styles’); the wp_enqueue_style takes some parameters. In the example above I am using: A … Read more