Load custom css after bootstrap

The above looks correct, however, you need to specify your script to enqueue after bootstrap by adding the bootstrap-min handle to the third, dependencies parameter. function register_css() { wp_register_style( ‘bootstrap-min’, get_template_directory_uri() . ‘/css/bootstrap.min.css’ ); wp_register_style( ‘custom-css’, get_template_directory_uri() . ‘/css/custom.min.css’, ‘bootstrap-min’ ); wp_enqueue_style( ‘bootstrap-min’ ); wp_enqueue_style( ‘custom-css’ ); } add_action( ‘wp_enqueue_scripts’, ‘register_css’ ); See wp_register_style for … Read more

Understanding child theme functions.php

What I read is that the parent css was loaded after the child, so the last one wins It depends on the order in which theme developer is loading stylesheets. Normally WordPress loads child theme’s functions.php first and then parent theme’s functions.php. the parent Emmet theme uses CSS files called differently than Style.css Yes it … Read more

Prevent CSS/JS loading when plugin is not used

You need to use action wp_enqueue_scripts except wp_head like: function inf_remove_junk() { if (!is_admin()) { wp_dequeue_style(‘js_composer_front’); wp_dequeue_style(‘js_composer_custom_css’); wp_dequeue_script(‘wpb_composer_front_js’); } } add_action( ‘wp_enqueue_scripts’, ‘inf_remove_junk’ ); But it remove the scripts from front end. I think on archive pages VC does not execute it’s shortcode. So you can check is_archive() condition instead of is_admin(). Or you can … Read more

Dequeue only stylesheets but not inline style added using wp_add_inline_style

wp_add_inline_style must accompany with an existing enqueued style. So the moment you dequeue or deregister that style, the associated inline style also gets dequeued or deregistered. To avoid that, you must first retrieve the inline style and then dequeue. Method-1: If after dequeueing theme-dynamic-styles handle, you don’t want to enqueue a new one in its … Read more

Best spot for wp_register_script() and wp_register_style()

Scripts and styles can be registered on the wp_loaded hook and then later enqueued using wp_enqueue_scripts. Once the scripts and styles have been registered, they can be enqueued later using just the handles that they were originally registered with. // Register scripts/styles. They can be optionally enqueued later on. add_action( ‘wp_loaded’, ‘wpse_register_scripts’ ); function wpse_register_scripts() … Read more

I register and enqueue stylesheet but nothing is rendered

You’re doing well – just one thing you need to change, and I reckon it’s a totally reasonable mistake to make: This: add_action(‘wp_enqueue_styles’, ‘alpha_styles’); needs to become add_action(‘wp_enqueue_scripts’, ‘alpha_styles’); Why scripts? Because there is no WordPress action called wp_enqueue_styles. Although the functions are named wp_register_style & wp_enqueue_style, you still need to hook them to the … Read more