1

functions.php の wordpress ロード プラグイン css/js を参照し、@ maiorano84 が回答した条件付きタグを使用

私はWordpress用のcformsFancyBoxWP Page Numbersプラグインを使用しています。ページ スピードの観点から、これらのプラグインの CSS と JS を、単一の投稿ページを除くすべてのページから削除したいと考えています。また、JS スクリプトをフッターに配置したいと考えています。以下は私が試したコードですが、うまくいきません。体は私を助けてくれますか?

if ( !is_single() ) {
add_action( 'wp_print_styles', 'my_deregisters', 100 );
add_action( 'wp_print_scripts', 'my_deregisters', 100 );

    function my_deregisters() {
        remove_action('wp_head', 'wp_page_numbers_stylesheet');
        wp_deregister_style( 'fancybox' ); 
        wp_deregister_script( 'fancybox' ); 
        wp_dequeue_script('fancybox');      
        wp_dequeue_style('fancybox'); 
        remove_action('wp_print_scripts', 'mfbfw_load');
        remove_action('wp_print_styles', 'mfbfw_css');
        remove_action('wp_head', 'mfbfw_init');
        remove_action('wp_head', 'cforms_style');

        }

} else {  }
4

0 に答える 0