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