You are doing it correctly. I would suggest two enhancements:
- Do not put this code directly in header.php. Create a custom function to print the css and hook this into the wp_head action.
- Always sanitize/escape input before you print it to the screen. Look into ctype_xdigit() for creating a custom function to sanitize you color value.
Related Posts:
- Assign title-specific class to list items in menu based on WP pages
- How to Edit the Order of Global Colors in Elementor? [closed]
- Correct way to output styles gathered from theme or plugin settings?
- How to display custom style based on theme option select box
- Selector for page to set up scrolling plugin
- Elementor – Edit Global Colors Order
- Default paragraph block styles just for pages NOT for posts?
- How to set different color in a select box due to selection with css
- How to insert spaces/tabs in text using HTML/CSS
- How to make the HTML link activated by clicking on the
- ?
- How would you make two s overlap?
- CSS text-align not working
- How can I insert vertical blank space into an html document?
- How can I make Bootstrap columns all the same height?
- Align text to the bottom of a div
- How to make a
- display in a horizontal row
- CSS3 Scale Animation Keyframes
- JavaFX css themes
- Border Position
- Responsive Canvas in Bootstrap column?
- How do you avoid caching during development?
- Are there Gutenberg container blocks?
- Get parent category class in post_class()
- Why won’t child theme’s style.css override plugin’s css
- How to create a Page alias in WordPress
- some things in child theme css not overriding parent
- Is it possible to create a full width row in WordPress’s editor window? [closed]
- How do I find (index) file in order to change style on CSS?
- Enqueue style for Password Reset page
- How to change header & footer to full width? [closed]
- Styleswitcher or themeswitcher to allow user to switch back to standard view from mobile device
- If post by specific role different css to everyone
- removing my underline from hyperlinks
- How to override Gutenberg admin CSS
- WordPress stripping out BR tags, need assistance
- Use wp_add_inline_style to add code to before wp_head?
- How to Remove White Space above video Block
- Output terms to post_class()
- How do I get blog posts to appear within CMS?
- Layout using Bootstrap not aligning correctly
- No styling on fresh wordpress installation
- How to include .css code in a WordPress page template?
- Enqueue Style Function Not Loading
- What makes WP so SEO friendly?
- what could cause get_stylesheet_directory_uri() to fail?
- Delete a white space using css
- wordpress css file
- CSS – Initial HTML Margin Issue On WordPress Site
- Cannot set property ‘className’ of null at setThemeFromCookie
- jQuery UI Theme that aligns perfectly with the admin UI
- Add class to navigation link of page
- My CSS suddenly doesn’t load anymore [closed]
- Is there a way to add new div class via a theme’s Additional CSS interface?
- Keep comments but turn off commenting
- How can I move my custom css to the very bottom of the head section?
- Long post titles don’t move to next line
- How to not load stylesheet and how to load a second stylesheet on a page
- Change the search icon in twenty fourteen
- styling isnot working in wordpress theme
- Plugins not showing up for custom template
- Using True Type Fonts (ttf) [closed]
- Horizontal drop down category with hover effect working
- Invert porfolio item order
- WordPress Sudden Loss of All CSS And Tons of JQuery Errors
- Can’t find a tag to style
- Custom CSS on mobile
- Removing Image Links from Custom Post Type
- Add inline CSS to login page with wp_add_inline_style
- Cannot add a class to metabox
- CSS does not Update
- I want to transfer my additional css code to my theme file–?
- WordPress changing content:”” to content: "
- How to customize Metaboxes?
- Change image using only CSS [closed]
- theme RTL make big white space in mobile mode and you need to scroll to see the site
- Why child theme stylesheet takes long time to update?
- Content going full width even though container is not
- I want to change change the arrangement of the grid of posts displayed by the theme on the Search page (read the description for better understanding)
- Align divs in a basic WordPress site
- Can’t center post thumbnail with bootstrap [closed]
- Force include a stylesheet from parent theme
- How can I override an existing custom CSS rule for a specific page
- Blank white space where header was [closed]
- Site name not showing in browser bar, only url
- Style tag on wp_footer
- Display current category without an active link in wp_list_categories
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- Outputting the blogposts or the_content()
- WordPress with PageLines theme: how to change the background color of a page? [duplicate]
- Apply Classes to post text inside editor
- Twenty Twelve theme: remove margins
- Parent style messing up with Bootstrap [closed]
- WordPress CSS not working properly
- Is there a way to edit the fonts of headings without a plugin (in the 2022 theme)?
- can i custom rendered content from API?
- custom css in one page
- How to include Elementor CSS in custom php file [closed]
- How to add CSS to WordPress
- How to add arbitrary custom CSS to a WordPress Block Theme using Site Editor?
- Wrap post titles containing slashes on narrow viewports