Once the widgets are being evaluated, the head of your site is completed, so you cannot use wp_head
anymore.
Adding <style>
tags is an option, but will indeed generate a warning from the validator.
Using the customizer is possibly confusing, because it is supposed to be about theme looks in general, not about specific widgets.
You can however, make a clever combination of inline styles in the widget and media queries in the widget style file. Have your widget generate html code like this:
<a>
<span class="mobile" style="color:blue;">
<span class="normal" style="color:red;">
link
</span>
</span>
</a>
Then add the following css in your style file:
@media only screen and (max-width:960px) { .normal {color:inherit !important;}}
On mobile browsers this will make the inner <span>
take its color from the outer <span>
.
Related Posts:
- Add class to before_widget for all widgets with a dropdown and a counter
- Adding inline styles from a widget
- Adding WordPress colorpicker in widget settings
- wp_head() not inserting the default stylesheet style.css
- How to check if a WordPress core block is active in sidebar
- How to add CSS class to custom logo?
- Solutions for generating dynamic javascript / CSS
- Why is wp_head() creating a top margin at the top of my theme header?
- How to store widget fields data as an array?
- Call dynamic_sidebar but include/exclude named widgets?
- How to control initial wp_head() output?
- How to determine the current widget’s parent container (sidebar widget id)
- Adding widgets programatically: how to avoid collisions?
- Why max-width:97.5% on content images?
- add generated stylesheet from parent theme after child-themes style.css
- why does twenty eleven theme mix up the css measurement units?
- File included into functions.php via require_once() won’t echo?
- Can’t edit style.css in subdirectory of my theme?
- Adding dashicon fonts to the admin of pre 3.8 installs
- modify a output of a widget
- How to Handle CSS for Multiple Header header.php Files?
- Should use widgets in this case?
- Enabling Default Widgets in a Custom Theme
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- How to add multiple custom widget areas
- How do I display the “Archives” widget layout (sidebar) in WordPress by ‘year’ then by ‘months’?
- There’s an image named g.gif somewhere in my WordPress site
- How to highlight the current page in the nav menu?
- Root Sage theme styles are not working!
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- Add tinymce to widget textareas
- Sub folder CSS that’s read by Admin panel
- Widgets with groups / sub widgets? Widget in a widget?
- WordPress 5.8 update problem custom theme styles are overridden by core styles common.min.css
- CSS won’t style output of wp_nav_menu() correctly
- Is it necessary to prefix every css class in a theme framework?
- Dequeue a style file which is making website load slow!
- Weekly background code not working
- searchform.php override not working
- Do I need normalize.css when developing my own WordPress-theme?
- How to float an image in Gutenberg
- Multiple Page Templates & CSS
- Can I have a widget and sidebars in custom theme?
- Disable dashboard drag&drop
- How to add material design css in wordpress and woocommerce
- Font Awesome 5 Free – far working but fas is not? [closed]
- What is the safe way to print tracking code / pixel code before tag or tag
- How to get javascript slider to work! [closed]
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- How to i style the elements from the TinyMCE
- Using page-id-{ID} from body_class() in local dev, versus live staging
- How to use widget in a widget-less WordPress theme?
- Is it acceptable for a WordPress theme to not accept widgets?
- Custom image size vs CSS sizing
- How to rotate every letter in a title
- theme style is applied on the dhasboard rather than the website
- Iris color picker in custom theme option page not saving value
- SVG in list-style-image breaks when adding fill
- How to style bootstrap container in wordpress theme?
- CSS added through customizer neglects the need of a child theme?
- How to override template files in parent theme?
- LESS not working in WordPress [closed]
- Place title (in correct place) above image with opaque background [closed]
- multiple html/css files for wordpress theme?
- CSS preprocessor file messed up after compiled
- Allow different tags in widget titles
- Why I obtain different visualization when I run the website on my local machine and on remote server?
- my single.php is mixup on some post for no reason
- How to use the _S framework
- How to use Canonical URL meta tag to avoid duplicate content issues with WP home pages
- Available widgets is not showing up?
- style variations hurt the editing performance
- Why nav_menu_css_class doesn’t work with apply_filters?
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- Default customizer colors aren’t displayed outside of the preview
- Text widget is placing everything side by side. I want to post it above
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- WordPress doesn’t load css, image and js files after moving local installation folder
- How to generate a rtl.css file for themes?
- Load multiple css simultaneously using functions.php
- overlay post title over post’s featured image
- Display problems in admin dashboard when creating a new theme from scratch
- Change site title color on individual pages
- Mobile view logo background colour in wordpress
- Create new sidebars trough admin post/page metabox
- Enqueue Stylesheets After Theme’s “rtl.css”
- WordPress 3.5 + Foundation 5 not working on IE9
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- WordPress widgets manager option for emulating theme layout
- adding navigation to genesis themes
- How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
- Option to show/hide widget depending on is_home?
- Header is not showing full width
- How do I middle-align my header menu items in WordPress [closed]
- How to resize video lightbox popup in wordpress? [closed]
- How can I get rid of the distance when I’m using list-style-type: none? [closed]
- HTML to WORDPRESS [closed]
- Theme.json: creating different sections of the color palette
- Is there a way to prevent wp_head from outputting self-closing tags?
- Image and font support missing in editor when deploying theme remotely