Adding external stylesheet after ALL other styles

It’s not elegant but it works. Add these lines to functions.php: ob_start(); add_action(‘shutdown’, function() { $final=””; $levels = ob_get_level(); for ($i = 0; $i < $levels; $i++) { $final .= ob_get_clean(); } // append styles just before </head> $final = str_replace( “</head>”, ‘<link rel=”stylesheet” src=”https://wordpress.stackexchange.com/questions/271293/mycss.css”></head>’, $final ); echo $final; }, 0); Alternatively you can move … Read more

Enqueueing scripts and styles multiple CPTS

There is a built-in function that you can use, instead of globals. The get_current_screen() function allows you to get the information associated with the current page. One of its return values is post_type. So you can check against an array of post types to see if anyone matches. function fhaac_admin_enqueue_scripts(){ $screen = get_current_screen(); if ( … Read more

How to dequeue theme’s RTL stylesheet?

RTL stylesheet is not loaded with wp_enqueue_style() so it wouldn’t appear in global $wp_styles variable. WordPress loads it with get_locale_stylesheet() function. You can remove loading locale scripts completely: function abort_loading_rtl_stylesheet() { remove_action( ‘wp_head’, ‘locale_stylesheet’ ); } add_action( ‘init’, ‘abort_loading_rtl_stylesheet’ ); or filter its output to load your custom rtl stylesheet: function override_default_rtl_styles(){ return ‘path/to/custom/rtl.css’; } … Read more

Theme in wp-content but my index.php search theme files in root

I assume you are adding your stylesheets like this in your header: <link rel=”stylesheet” type=”text/css” href=”https://wordpress.stackexchange.com/questions/285785/css/style.css”> Which won’t work. To construct the path dynamically, you need to use the PHP functions offered for this. Make sure your header has <?php wp_head(); ?> in it, and then enqueue your style in your theme’s functions.php file as … Read more

Stylesheet not linking

get_template_directory_uri() just returns the directory of the current theme, not the link to the actual stylesheet. In functions.php try: function register_directories_style() { wp_register_style(‘style’, get_template_directory_uri().’/style.css’, [], 1); wp_enqueue_style(‘style’); } add_action( ‘wp_enqueue_scripts’, ‘register_directories_style’); if you wanted to select a different stylesheet, you just updated the $src arguement. e.g. function register_directories_style() { wp_register_style(‘directory_style’, get_template_directory_uri().’/css/directories.css’, [], 1); wp_enqueue_style(‘directory_style’); } … Read more

Use wp_add_inline_style to add code to before wp_head?

Yes, that should be doable. Just enqueue your inline styles with callback hooked to wp_enqueue_scripts and priority set to 0 (assuming other styles are loader later / lower priority / bigger number). You also need to register a dummy handle to which you attach the inline styles to, so no other styles are loaded before … Read more