Reputation: 2663
I am attempting a relatively simple modification of code provided by Woocommerce to remove the handheld navigation bar on a single page of my site with the slug register
.
The code snippet provided is:
add_action( 'init', 'jk_remove_storefront_handheld_footer_bar' );
function jk_remove_storefront_handheld_footer_bar() {
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
}
I want to remove the menu only for a single page, so I tried to use the is_page
hook.
add_action( 'init', 'remove_storefront_handheld_footer_bar' );
function remove_storefront_handheld_footer_bar() {
if (is_page( $page = 'register' )){
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
}
}
However, this does not remove the handheld menu. If I remove my is_page
logic, then the menu disappears but that is not the functionality I need.
Upvotes: 3
Views: 568
Reputation: 253919
You can use instead storefront_footer
(the same hook) with a higher priority (lower number) than the priority used in remove_action()
like:
add_action( 'storefront_footer', 'remove_storefront_handheld_footer_bar' );
function remove_storefront_handheld_footer_bar() {
if ( is_page( 'register' ) ){
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works (with any specific page ID, name or slug). You need to be sure that "register"
is the slug of a real existing "page".
Upvotes: 1