WordPress

How To Remove All Actions For Wp_Head Or Wp_Footer For Specific Page

Here we learn about how to remove all actions for wp_head or wp_footer for a specific template page.

Custom code copied and paste into your child theme’s functions.php file.

Here is an example for checking for a particular page by slug ‘my-workshop’.

<?php
function myblog_unhook_wp_head_footer(){
  global $wp_filter;
  if( is_page( 'my-workshop' ) ) {
    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', 'myblog_unhook_wp_head_footer' );
?>
Rahul Prajapat

I’m Rahul Prajapat. I’m a WordPress developer and Author at TheCodeHubs. I have good skill of Html, CSS, JQuery, SQL, Web API, PSD to HTML/PSD to WordPress, WordPress Theme/Plugin Customization, create or modify short code, customize visual composer short code or integrate new short code with visual composer, can create custom metabox for any post type in WordPress admin.

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago