How to remove all actions for wp_head or wp_footer for specific template page or as you want

For remove all css and scripts file just copy and paste below code into your functions.php and change according to your need

function rj_unhook_wp_head_footer(){
    global $wp_filter,$wpdb,$wp_query;
    if(is_page('advanced-workshop')) // here i checking for particular page by slug
    {
foreach ( $wp_filter['wp_head'] as $priority => $wp_head_hooks ) {
if( is_array( $wp_head_hooks ) ){

foreach ( $wp_head_hooks as $wp_head_hook ) {
                 
                remove_action( 'wp_head', $wp_head_hook['function'], $priority );
}
}
}
foreach ($wp_filter['wp_footer'] as $priority => $wp_footer_hooks ) {
if( is_array( $wp_footer_hooks ) ){
foreach ( $wp_footer_hooks as $wp_footer_hook ) {
remove_action( 'wp_footer', $wp_footer_hook['function'], $priority );
}
}
}
    }  
}
add_action( 'wp', 'rj_unhook_wp_head_footer' );

Comments

  1. But what if I need to run only one plugin on my page template (contact form), but not want to load all the stuff from other plugins? How to organize it?

    ReplyDelete

Post a Comment

Popular posts from this blog

How to add image option in nav menu in wordpress

How to add a custom email functionality in woocommerce,wordpress for example new email template for shipping order

How to change user id on checkout page for assign order to different user in woocommerce wordpress