plugin enqueue style on all pages

You’re enquing on the admin_enqueue_scripts hook, which is why it’s only showing up on admin pages If we look at an example from the official documentation: /** * Proper way to enqueue scripts and styles */ function wpdocs_theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, … Read more

WordPress Child theme fails to override parent theme css

I see the issue, there is a second call to main.css : <link rel=”stylesheet” id=”faxhion-css” href=”http://www.rareselect.co.uk/wp-content/themes/faxhion/main.css?ver=4.8.1″ type=”text/css” media=”all”> <link rel=”stylesheet” id=”faxhion-child-css” href=”http://www.rareselect.co.uk/wp-content/themes/faxhion-child/style.css?ver=0.1″ type=”text/css” media=”all”> <link rel=”stylesheet” id=”plugins-css” href=”http://www.rareselect.co.uk/wp-content/themes/faxhion/assets/css/plugins.css?ver=4.8.1″ type=”text/css” media=”all”> <link rel=”stylesheet” id=”fontawesome-css” href=”http://www.rareselect.co.uk/wp-content/themes/faxhion/assets/css/font-awesome.min.css?ver=4.8.1″ type=”text/css” media=”all”> <link rel=”stylesheet” id=”style-css” href=”http://www.rareselect.co.uk/wp-content/themes/faxhion/assets/css/main.css?ver=4.8.1″ type=”text/css” media=”all”> The one you are calling with id=”faxhion-css” its loading nothing its a 404 … Read more

Enqueue a file that’s not js or css

You could also look to create a special CSS file that you setup an htaccess rewrite rule for. For example wp-content/yourtheme/custom.css And then add a rule in your htaccess: RewriteEngine On RewriteRule ^/wp-content/yourtheme/custom.css$ /wp-content/yourtheme/styles.php [L] You can then call wp-load inside this styles.php file, do any sort of logic required, before outputting your custom css … Read more

Proper Way to Load stylesheet on Condition

You’ll need to put the if statement around the line that enqueues in the first place. // enqueue styles for child theme function wowdental_enqueue_styles() { // enqueue parent styles wp_enqueue_style(‘Divi’, get_template_directory_uri() .’/style.css’, get_the_time() ); // Flip3d css // flip3d only on home page if( is_home() ) { wp_enqueue_style( ‘flip’, get_stylesheet_directory_uri() . ‘/css/flip.css’, get_the_time() ); } … Read more

dynamic name of the style for wp_enqueue_style

this syntax doesn’t seem right to me. First of all what is ABS_URL? If it’s a constant that you’ve defined earlier, then there is an ‘ missing before /includes/box.css’. The code should look like this: $name=”mystyle”; wp_enqueue_style( $name .’-style’, ABS_URL . ‘/includes/box.css’, false ); It works as it should, the output is: <link rel=”stylesheet” id=’mystyle-style-css’ … Read more

How to register and set http/2 server prefetch for a specific asset?

Support for resource hints in WordPress is done through rel attribute of <link> elements whithin the HTML docuemnt, not with HTTP/2 server push (which uses Link headers in the HTTP response). You can use wp_resource_hints filter to add the URLs you need the prefetch like this: add_filter( ‘wp_resource_hints’, ‘cyb_resource_hints’, 10, 2 ); function cyb_resource_hints( $urls, … Read more

Enqueue style for specific site type

is_tax() and is_404() perhaps? https://codex.wordpress.org/Conditional_Tags UPDATE: I’m sorry my original answer was vague, to elaborate better: You can add conditional tags in a wp_enqueue_scripts hook, choosing to register and enqueue when criteria is met, like so: add_action( ‘wp_enqueue_scripts’, ‘mythemes_scripts’ ); function mythemes_scripts() { if (is_category()) { wp_register_style( ‘categoryStyles’, get_template_directory_uri() . ‘/style-category.css’, array(), // maybe the … Read more