Disable ShiftNav on a specific page (or any custom condition)

Removing the ShiftNav markup

ShiftNav’s content is added to your site via hooks. To remove the ShiftNav markup on specific pages, you can remove these hooks on those pages.

To target a specific page, you’ll generally want to test for that page conditionally. In the following example, ShiftNav would be removed from page 1380:

add_action('wp', 'remove_shiftnav', 5);
function remove_shiftnav(){
	if (is_page(1380)) {
		// Remove menu bar and main ShiftNav panel
		remove_action('wp', 'shiftnav_inject');

		// Remove additional panels generated with ShiftNav Pro
		remove_action('wp_footer', 'shiftnav_pro_generate_menus');
	}
}

You can tailor the condition to your specific needs. Here’s a list of WordPress Conditional Tags

Generally, this code works best in a child theme’s functions.php file

Removing styles and scripts

To remove ShiftNav’s CSS and JS assets, you can use

add_action( 'wp' , 'remove_shiftnav_assets' );
function remove_shiftnav_assets(){
	if( is_page( 1380 ) ){
		remove_action( 'wp_enqueue_scripts' , 'shiftnav_load_assets' , 101 );
		remove_action( 'wp_enqueue_scripts' , 'shiftnav_pro_load_assets' , 20 );
		remove_action( 'wp_head' , 'shiftnav_inject_css' );
	}
}

On this page