0

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');
3
  • 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.
    – gmazzap
    Commented Sep 23, 2013 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. Commented Sep 23, 2013 at 15:51
  • Understood. The problem now is that it does not load the CSS.
    – Dz.slick
    Commented Sep 23, 2013 at 15:58

1 Answer 1

3

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');

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.