Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to enqueue my custom script and style with the block of codes, the scripts works but not the style. I don't know what I'm doing wrong.

    function my_scripts_method() {

        wp_deregister_script( 'jquery' );
                    wp_deregister_script( 'style' );

            wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
                    wp_register_style( 'style', '//siteripe.com/style.css' );    
   }    


    add_action('wp_enqueue_scripts', 'my_scripts_method');
    add_action('wp_enqueue_style', 'my_style_method');
share|improve this question
2  
God's punishing you for unregistering jquery. :-) Joking, but deregistering jquery is really a worse practise. You have to wp_enqueue_script jquery, registering it's not enough to show it in a page. –  G. M. Sep 23 '13 at 15:46
1  
@G.M.'s right, you don't want to deregister jquery in general. What do you want from 1.7.2 that's not available in the version bundled with core? I bet we can help you with the js. –  Andrew Bartel Sep 23 '13 at 15:51
    
Understood. The problem now is that it does not load the CSS. –  Dz.slick Sep 23 '13 at 15:58

1 Answer 1

up vote 3 down vote accepted

I think you are using the wp_enqueue_style the wrong way as it is not an action hook. wp_enqueue_scripts action hook is being used for enqueuing both scripts and styles. try this:

function my_scripts_method() {

        wp_deregister_script( 'jquery' );
        wp_deregister_script( 'style' );

        wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
        wp_register_style('style', '//siteripe.com/style.css' );
        wp_enqueue_style('style'); 
} 
add_action('wp_enqueue_scripts', 'my_scripts_method');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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