I have added my dynamically generated stylesheet by this way.

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/style-options.php';

And to hook into theme I did

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

add_action('wp_footer', 'my_login_css');

My question: Is there any way to hook stylesheet other than this old fashioned way, like wp_register_style or wp_enqueue_style?

1 Answer 1


This is the recommended way to add a custom or second style sheet for child themes:

function custom_style_sheet() {

wp_enqueue_style( 'custom-styling', get_stylesheet_directory_uri() . '/css/custom.css' );


add_action('wp_enqueue_scripts', 'custom_style_sheet');

You can also add style sheets conditionally http://wpsites.net/wordpress-themes/second-style-sheet-theme/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.