How can I force Dynamic CSS via ACF values to update on page load?

Per Tony’s suggestion, adding a random string to the CSS version did the trick. Here’s the code I used to do that. First this code to generate the random number. // get theme version function cd_get_version() { $theme_data = wp_get_theme(); return $theme_data->Version; } $theme_version = cd_get_version(); global $theme_version; // get random number function cd_get_random() { … Read more

How to apply CSS based on publishing date

You can compare the post date to the date of your choice and enqueue different styles depending on the result: <?php function my_enqueue_styles_depending_on_date() { global $post; $style_switch_date=”20201230″; // the trigger date if ( is_single( $post->ID ) ) { $post_date = get_the_date( ‘Ymd’, $post->ID ); if ( $post_date > $style_switch_date ) { wp_enqueue_style( ‘css_for_newer_posts’ ); } … Read more

How to sync the style in the visual editor with the style of a child theme?

The parent theme’s functions.php has two functions to manage the editor styles. They are twentytwenty_classic_editor_styles() and twentytwenty_block_editor_styles() and they’re both hooked to init. For example, the classic editor function reads: function twentytwenty_classic_editor_styles() { $classic_editor_styles = array( ‘/assets/css/editor-style-classic.css’, ); add_editor_style( $classic_editor_styles ); } add_action( ‘init’, ‘twentytwenty_classic_editor_styles’ ); To override those styles, copy both of those functions … Read more

My CSS suddenly doesn’t load anymore [closed]

You should remove an additional } on line 18. Try the following <?php if (!function_exists(‘understrap_scripts’)) { /** * Load theme’s JavaScript and CSS sources. */ function understrap_scripts() { // Get the theme data. $the_theme = wp_get_theme(); $theme_version = $the_theme->get(‘Version’); wp_enqueue_style(‘slider-slider-styles’, ‘https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css’); wp_enqueue_style(‘lity-style’, ‘https://cdnjs.cloudflare.com/ajax/libs/lity/2.4.1/lity.min.css’); $css_version = $theme_version . ‘.’ . filemtime(get_template_directory() . ‘/css/theme.min.css’); wp_enqueue_style(‘understrap-styles’, get_stylesheet_directory_uri() . … Read more

Add core style in theme

wp_head() is absolutely required for WordPress themes. It is how your theme should be adding styles, and it’s how plugins can add their own scripts styles. Without it (and wp_footer(), which is also required) your theme will not function correctly. WordPress does not load many styles itself, but the styles it does add are for … Read more

Newbie wordpress question re banner height

There’s no method in WordPress’ UI for adding CSS for a single page only, if that’s what you’re asking for. There might be plugins available that offer it, though, but discussing that would be off topic here (I’d suggest a local community group or similar if you’re asking for plugin recommendations). The simplest “proper” way … Read more

plugin dev – minimum base css specificity?

There’s no standard. CSS specificity in themes varies wildly, and I’m convinced many theme authors are not even aware of the concept given some of the CSS I’ve seen. If something is very important to the appearance of your plugin, then high specificity may be desirable, but in many cases if you’re just styling divs … Read more