Support » Fixing WordPress » Database driven CSS using parse_request()

  • According to : 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'; ?>
    add_action( 'parse_request', 'my_custom_wp_request' );

    any insights will be much appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Database driven CSS using parse_request()’ is closed to new replies.