Title: Database driven CSS using parse_request()
Last modified: August 19, 2016

---

# Database driven CSS using parse_request()

 *  [HelgaTheViking](https://wordpress.org/support/users/helgatheviking/)
 * (@helgatheviking)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/database-driven-css-using-parse_request/)
 * According to : [http://josephscott.org/archives/2010/03/database-powered-css-in-wordpress-themes/](http://josephscott.org/archives/2010/03/database-powered-css-in-wordpress-themes/)
   you can hook into the parse_request() function to get it to serve up a php file
   as CSS…. which would then allow you to pull CSS from a database. helpful as this
   is a common feature in theme options, except i can’t get it to work for anything.
 * i enqueue the pseudo script so that it shows up in the header
 *     ```
       function kia_wp_head() {
         wp_enqueue_style('dynamic', get_bloginfo('stylesheet_directory') . '/admin/ . '?my-custom-content=css');
       }
       add_action('wp_print_styles', 'kia_wp_head');
       ```
   
 * and then my custom parse request, which i dont think ever gets called… or _if_
   it does isn’t adding changing any CSS:
 *     ```
       function my_custom_wp_request( $wp ) {
           if( isset($_GET['my-custom-content']) && $_GET['my-custom-content'] == 'css'  ) {
   
               # get theme options
               header( 'Content-Type: text/css' ); ?>
   
       body {
           background-color: <?php echo 'red'; ?>
       }
   
       <?php
               exit;
           }
       }
       add_action( 'parse_request', 'my_custom_wp_request' );
       ```
   
 * any insights will be much appreciated.

Viewing 1 replies (of 1 total)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/database-driven-css-using-parse_request/#post-1896550)
 * You might find the answer you’re looking for on one of the following pages.
    
   [How do I add CSS options to my plugin without using inline styles?](http://wordpress.stackexchange.com/questions/1445/how-do-i-add-css-options-to-my-plugin-without-using-inline-styles)
   [Generating CSS Files Dynamically Using PHP Scripts?](http://wordpress.stackexchange.com/questions/1560/generating-css-files-dynamically-using-php-scripts)
 * Hope that helps. 🙂

Viewing 1 replies (of 1 total)

The topic ‘Database driven CSS using parse_request()’ is closed to new replies.

## Tags

 * [dynamic CSS](https://wordpress.org/support/topic-tag/dynamic-css/)
 * [parse_request](https://wordpress.org/support/topic-tag/parse_request/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/database-driven-css-using-parse_request/#post-1896550)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
