Skip to content

This repo is for WordPress developers who wants to output dynamic css of their themes or plugins as External css and not internal inline css

License

Notifications You must be signed in to change notification settings

garousiamir/dynamic-css-in-WordPress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic CSS in WordPress

This repo is for WordPress developers who want to output dynamic CSS of their themes or plugins as external CSS and not internal inline CSS

dynami_css

How to use it?

  1. First of all, you need to download this repo using git clone or manual download and put it somewhere in your theme.
  2. Require the file to load the dynamic CSS loader class, Example Bellow:
 require_once get_template_directory() . '.../path/to/ag-dynamic-css.php';
  1. Now create a file named custom.css.php in the root directory of your theme. Now open the custom.css.php and put your dynamic CSS.

    For example imagine that I have a dynamic css from my theme options like this: $color= $options['opt-color-5']; with this example in mind inside my custom.css.php would be something like bellow:

    // ... this code is just an example ...
    .nav-responsive-content .discounts-contact .discount {
     color: <?php echo $color;  ?> ;
     }
     .nav-responsive-content-menu li.has-child > .children .heading {
         color: <?php echo $color;  ?> ;
     }
     // ... rest of your css goes here ...
    
  2. If you have followd the steps correctly you can see the custom.css is rendering in your front end just like other css files.

About

This repo is for WordPress developers who wants to output dynamic css of their themes or plugins as External css and not internal inline css

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages