• [ Moved to the Fixing WordPress sub-forum. ]

    I am very new to wp and I would like to insert some CSS into just one page using the style register and style enqueue method. Right now it works fine when the CSS is in my footer but I would like to do it the preferred way. This is my code:

    #sig
    {
    color:#00ff00;
    background-color:#000000;
    width:82px;
    border:6px solid powderblue;
    }

    and here are all my questions:
    1. I would create a file with name: my_stylesheet.CSS and put it in a new folder in my root directory (my wp sits in C:\xampp\htdocs\WP). That would be C:\xampp\htdocs\WP\my.CSS (Am I right?)
    2. would my $handle be my_stylesheet.CSS ?
    3. would I than go into functions.wp-styles.php in WP subdirectory wp-includes and open it, and go to the following code:

    function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
    _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

    return wp_styles()->add( $handle, $src, $deps, $ver, $media );
    }

    Here I would copy the above function but change $handle to ‘my_stylesheet.CSS’,
    and change $src to ‘\my.CSS\my_stylesheet.CSS’,,,)

    After registering I would do same thing using function wp_enqueue_style()

    4. Last thing would be to add the code:
    add_action(‘my_stylesheet.CSS’,’\my.CSS\my_stylesheet.CSS’)

    These are “detail” that I am not sure off. I might also be completely off.
    Please, help.
    Vlad

Viewing 2 replies - 1 through 2 (of 2 total)
  • @vladkara

    This doesn’t answer your question but…

    If your intention is to only add the CSS code mention in your post, you don’t need to create a new CSS file.

    Since you’re using WordPress 4.7, you can go to the customizer and add the code directly from there (Under Additional CSS).

    Let me know if you need more help

    Thread Starter vladkara

    (@vladkara)

    Thank you for your help. It did work immediately.
    Now my question is: Did the customizer added my extra css code by enqueueing? In which file did it actually go?
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to insert CSS stylesheet using enqueue’ is closed to new replies.