One way of doing this would be to create a “CSS” file from PHP. In other words, create a file, call it something like style.css.php, and at the beginning of the file put:
<?php header("Content-type: text/css");
Then, link that file in the head of your theme file. Because the style.css.php file is a PHP file, anything you can do in a normal PHP file can be done in this file. As such, you can pull theme option values from the database and use them. For example:
#header{
background: <?php echo get_option('my-header-background-color'); ?>
}
Of course, you need to get the options into the database first, but since your question didn’t address that, I won’t go into it here.
Related Posts:
- Using PHP to toggle stylesheet and header image, set in cookie
- Shortcode content output but not in correct place
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to style options page in dashboard?
- Css loads very slow [closed]
- responsive.css in the WordPress should be prioritized
- height should be set to auto to avoid pixelation in the post thumbnail function
- How to make container class in PHP
- Creating a mobile site by adding a new class to the body tag from functions.php
- CSS change in woo commerce Place Order Text [closed]
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- how to changes mobile menu toggle breakpoint in WordPress
- PHP function for horizontal Woocommerce thumbnails and badges
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- I got big white screen when i attach main style sheet of Html in functions.php
- Site title not showing. Please help me
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Add class for the_post_thumbnail_caption()
- Displaying POST content with HTML tags and all
- Highlight Single Page Ancestor
- Styling admin page rows in order of importance (checkboxes)
- How to have Function of a plugin using global vars into a shortcode?
- Cant get theme to change footer color through theme customizer
- How to add margin underneath woocommerce total price amount -> productpages
- How do I get Roboto Google Font to display normal font-style? [closed]
- Integrating CSS Into a WP Function Call [closed]
- Load slideshow.css file only if Slideshow is checked / on
- Sorting Problem
- How do I make a shortcode to display Dokan seller badge list?
- How can we upload custom page files?
- Calling a PHP function from a menu item
- Hide or Show Read More Button by Content Area
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 7146491840906359738 bytes)
- How do I get the author’s page url from their ID?
- How to check from which page the user is coming to the current page?
- Displaying Logged-In User Name and avatar in WordPress Menu
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Add before_content and after_content to register_sidebar
- Word Count Function Preventing Permalink Editing
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- Changing custom logo link
- Using if/else statements with output from theme options
- Auto-update products after they were published – Woocommerce
- php function to display commenter username or login
- How to change menu order item
- How can I make an object available through the entire site?
- WordPress admin-ajax.php
- How to use html inside a functions.php code?
- Nested “do” and “add” Actions is possible?
- Display Data in Table from External Database in WP using Shortcodes
- How to check if a Customizer setting is set?
- trouble with page_id & highlighting current page
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Remove item in Checkout
- How to get current post category details inside “loop”?
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Get the alt text of the image in a array
- Make table disappear when fields are left blank?
- Unzip file in functions.php, and add it to cron
- Add Block Before Entry Title Using PHP
- Timber right sidebar in WordPress theme
- How to Remove Theme Style CSS inside Custom Plugin?
- Dynamically populate parameter in Gravity Forms using PHP
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can i create a function tag in my plugin
- How to escape echo for input tag?
- WordPress Slider is not working
- Including user data in “new user notification email”
- Add Shortcode to ::before class
- Reload page with a different shortcode when a user selects from a dropdown
- Refresh page after login with litespeed cache
- Return newly created category by code
- Woocommerce Add custom “Add to cart button” in single page with tags
- Hook into all password resets in WordPress and get password before hashing?
- remove_action() not working in page template – Genesis
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Dropdown menu on custom menu
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- WordPress get_post_meta issue
- Woocommerce Price Text
- Show custom default avatar instead of gravatar
- Display pages from specific page template
- Sidebar doesnt get updated?
- ajax form function error
- Display custom meta box in my template file
- Simple Probléme in wordpress
- Add a “Next Post” & “Previous Post” styled button manually to a post
- Contact form with dynamic dropdown and filter
- Critical Error customiser
- Custom HTML/CSS Theme into WordPress – SEO considerations
- how to display custom taxonomies in front page
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Create custom API endpoint to change custom header image
- Can I associate a custom post type with another custom post type?
- Creating posts with php-script + csv
- Change WooCommerce Order status from frontend form submitted data
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)
- Add_filter just custom page types