Filters

Knowledgebase Docs » ShiftNav
USEFUL? 6

shiftnav_main_toggle_target

By default, the ShiftNav main toggle bar will toggle the main ShiftNav instance.

If you want to change this, you can use the shiftnav_main_toggle_target filter.

To use the filter, just return the instance ID of the ShiftNav instance that the toggle bar should control.

For example, let’s say you have two ShiftNav instances – the main instance, and an instance specifically for your Shop page called ‘shop’. On the shop page (which has an ID of 67), you want the main ShiftNav toggle bar to open the ‘shop’ ShiftNav menu, rather than the main ShiftNav menu.

Here’s the code that would do that:

add_filter( 'shiftnav_main_toggle_target' , 'my_custom_shiftnav_togglebar_target' );
function my_custom_shiftnav_togglebar_target( $instance_id ){
	if( is_page( 67 ) ){
		return 'shop';
	}
	return $instance_id;
}

Note: want to control which instance panels appear on which pages? See the PHP API use case

shiftnav_main_toggle_icon_class

Since 1.6.2

This filter allows you to change the main hamburger icon to a different icon via its class.

Example

This example code changes the icon to a rocket

add_filter( 'shiftnav_main_toggle_icon_class' , 'sn_custom_icon' );
function sn_custom_icon( $icon_class ){
	return 'fa fa-rocket';
}

shiftnav_main_toggle_content

This filter allows you to change the content of the toggle button, which by default is the hamburger button markup. You could add to the button, or replace it entirely.

Example

Since 1.6.2

This example adds the word “Menu” after the toggle icon

add_filter( 'shiftnav_main_toggle_content' , 'sn_custom_toggle_content' );
function sn_custom_toggle_content( $toggle_content ){
	return $toggle_content.= '  Menu';
}