• Hi people,

    I’m trying to remove the comment-reply.min.js from my pages, leaving the load just in post pages. Unfortunately sometimes I can remove but I can’t load again, sometimes I receive a notice message.

    Remove on load

    In the first time I used this function to drive the situation:

    function clean_header(){
    	if(!is_singular( 'post' ))
    		wp_deregister_script( 'comment-reply' );
    }
    add_action('init','clean_header');

    This approach doesn’t work because it ignore the conditional and always remove the script. Also, if I try to load the script after it inside the header.php using something like wp_enqueue_script( ‘comment-reply’ ), nothing happens.

    On the other hand, I can simply use wp_deregister_script( ‘comment-reply’ ). I have a function to unload the scripts (mostly jquery) to use different scripts in different directories. But, if I put this call inside of this function, I just receive a message like:

    Notice: Undefined index: comment-reply in wp-includes/class.wp-scripts.php on line 201
    Notice: Trying to get property of non-object in wp-includes/class.wp-scripts.php on line 201

    I think that I forget something in the middle of the process but I can’t imagine what. I’ve test a lot of different ideas but nothing happens.

    Someone have a clue about it?

    Thanks

Viewing 1 replies (of 1 total)
  • Jon (Kenshino)

    (@kenshino)

    Lord Jon

    If you want the script to not load on some pages, what you need is wp_dequeue_script with conditionals. Not de-register.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_deregister_script( 'comment-reply' ) give a notice error’ is closed to new replies.