• Resolved karthickr

    (@karthickr)


    Hi Team,

    Need to unload the Nooz related CSS and JS files from the unused Nooz plugin pages on my site. I have tried the post type as nooz_release in function.php and dequeue the nooz-basic CSS file.

    But, still loading it on other pages. Please find the code below

    add_action('wp_enqueue_scripts', 'unload_plugin_scripts');
    function unload_plugin_scripts() {
        if (get_post_type() != 'nooz_release') {
            wp_dequeue_style( 'nooz-basic' );
        }
    }

    Please check this code and resolve my problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor farinspace

    (@farinspace)

    @karthickr,

    The following should work to remove css/js from non-nooz pages. You will have to adjust the array for pages where the [nooz] shortcode is being used.

    add_action ( 'wp_enqueue_scripts', 'unload_nooz_plugin_scripts', 11 );
    function unload_nooz_plugin_scripts() {
    	global $post;
    	$is_release_post_type = 'nooz_release' == get_post_type();
    	$is_news_page = isset( $post->post_name ) && in_array( $post->post_name, array( 'news', 'news/press-releases' ) );
    	if ( ! $is_release_post_type && ! $is_news_page ) {
    		wp_dequeue_style( 'nooz-basic' ); // basic theme css (no js for basic theme)
    		wp_dequeue_style( 'nooz-outline' ); // outline theme css
    		wp_dequeue_script( 'nooz-outline' ); // outline theme js
    	}
    }
    

    Again thanks for the insight, you have brought up a good point about not loading nooz css/js on pages where they are not needed. The detection of the [nooz] shortcode could be tricky .. but I will add this to the TODO list for inclusion as core functionality to Nooz.

    Thread Starter karthickr

    (@karthickr)

    @farinspace.

    Thanks for the support. I have modified a few lines on your code and now it’s working good.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dequeue nooz-basic-css style from unwanted pages’ is closed to new replies.