Skip to main content
1 of 7
Jevuska
  • 1.2k
  • 10
  • 21

@Scott Reinmuth, I think you misdirection about those tutorials, yes you use parse_request methode.

If you follow, this code is a hook with function and you need to put in functions.php

<?php
    add_action( 'parse_request', 'my_custom_wp_request' );
    function my_custom_wp_request( $wp ) {
        if ( !empty( $_GET['my-custom-content'] ) && $_GET['my-custom-content'] == 'css' ) {
        # get theme options
        header( 'Content-Type: text/css' );
?>
         a { color: <?php echo get_option('some_other_option') ?> !important; }
<?php
        exit; 
        }
    }
?>

And in header.php with this code ( without file /css/theme_styles.php ) to make a request with parameter my-custom-content and value css. Thats why we need a hook with function to make it work.

<link rel='stylesheet' type='text/css' href="<?php bloginfo( 'url' ); ?>/?my-custom-content=css" />

we done here.


BUT if you need to use css in out side function, then you create custom-css.php and your function in functions.php will be like this:

add_action( 'parse_request', 'my_custom_wp_request' );
function my_custom_wp_request( $wp ) {
    if ( !empty( $_GET['my-custom-content'] ) && $_GET['my-custom-content'] == 'css' ) {
    # get theme options
       header( 'Content-Type: text/css' );
       require dirname( __FILE__ ) . '/css/custom-css.php';
       exit;
    }
}       

and inside your custom-css.php

a {
  color: <?php echo get_option('some_other_option') ?> !important;
} 

In header.php still the same above.

Jevuska
  • 1.2k
  • 10
  • 21