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 define and link full path to css located at a random folder on header.php
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- CSS not updating in browser when I change it
- Solutions for generating dynamic javascript / CSS
- Can I create my own “Recent Posts” widget or customize the existing one?
- Do I actually need to link my theme’s style.css in the theme files
- Why is wp_head() creating a top margin at the top of my theme header?
- How to store widget fields data as an array?
- Enqueue a stylesheet for login page and make it appear in head element
- Adding a div to wrap widget content after the widget title
- What is the difference between wp_register_sidebar_widget and register_widget?
- CSS classes for theme
- How to enqueue script if widget is displayed on page?
- Generating CSS Files Dynamically Using PHP Scripts?
- Enqueue Stylesheets After Theme’s “rtl.css”
- Caching and Versioning for rtl.css
- Are the WordPress Core CSS styles really all nessesary?
- Call dynamic_sidebar but include/exclude named widgets?
- Understanding wp_add_inline_style
- Should I use set_transient or update_option?
- Any alternate TinyMCE4 themes / subthemes?
- Splitting WordPress theme CSS into multiple files, good or bad?
- Hide a div that is part of all pages on one specific page
- HowTo: Add Class to Sidebar Widget List-Items
- Why I can’t add a CSS style in this WordPress theme?
- How to add Color Picker in Theme Options for the following?
- Can’t get staging site to display same way as live site. Completely stumped
- How to make a theme with more than one CSS file?
- How to control initial wp_head() output?
- Editing the custom background CSS
- register_sidebar ignores ‘id’ and ‘class’
- How wp_cache is supposed to work, and does it help with performance?
- How can I get wp_head() as a string instead of echoing it?
- How to edit an existing WordPress theme? [closed]
- How to determine the current widget’s parent container (sidebar widget id)
- Suggestions for creative use of post format feature, or themes that use them well
- 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
- Add a preview to a WordPress Control Panel
- Enabling Widgets By Default in Custom Theme Development
- why does twenty eleven theme mix up the css measurement units?
- Setting up partial Right-to-Left admin interface
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- 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
- Context aware widgets. My work in progress
- How to Handle CSS for Multiple Header header.php Files?
- How to determine which sidebar the widget has been added to, via widget admin?
- How can I add an incremental class identifier to my sidebar widgets?
- How to Modify a Widgets UL and/or LI Classes
- 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 create theme based widget that can be drop in sider bar or footer
- CSS in child theme not overriding the parent theme [closed]
- How to add (css) classes to only one wp_nav_menu()?
- How to add a text widget during theme activation
- Adding dashicon fonts to the admin of pre 3.8 installs
- Move my theme style.css into a folder
- Convert a static website to a WordPress theme and import all existing content
- How to keep theme layout the same when admin gray bar is present?
- Enqueued Stylesheets Effecting Admin Styles
- How to add multiple custom widget areas
- How do I display the “Archives” widget layout (sidebar) in WordPress by ‘year’ then by ‘months’?
- Custom CSS In Uploads Folder
- There’s an image named g.gif somewhere in my WordPress site
- How to highlight the current page in the nav menu?
- Writing Clean WooCommerce Styles
- First completely customized theme, where should I start?
- Root Sage theme styles are not working!
- De-registering parent style sheet css recommended?
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- Alterntives to BEM syntax that comply with WordPress coding standards? [closed]
- Modify Javascript Configuration Options for Theme Customizer Colour Picker
- Is it a good idea to make whole theme widgetized?
- Modify the Additional CSS section (adding a disclaimer)
- Theme Customizer – Choose where widget area appears, to let users organise widgets
- Add tinymce to widget textareas
- How to determine which registered sidebar area a custom widget is loaded into
- 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
- WordPress default theme css units
- How i can get widgets areas working in customizer?
- Cutomize Colors utility: How to add more configurable colors to a theme
- CSS won’t style output of wp_nav_menu() correctly
- How to determine if post has widget content?
- Where is definied the theme location for the main menu in a WordPress template?
- Is it necessary to prefix every css class in a theme framework?
- current-menu-item class not working