Filters

Knowledgebase Docs » ShiftNav
USEFUL? 0

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