Slicknav WordPress Filter to adjust values
The Slicknav WordPress Mobile Menu plugin version 1.6.2+ now has a filter action that allows you change certain values via your functions.php file.
The filter name is ( ‘ng_slicknav_slickNavVars’, $data ); it takes one parameter $data
What can be filtered:
| Slicknav Value | What it does | Value type |
|---|---|---|
| ng_slicknav_position | HTML element to append menu | string value |
| ng_slicknav_parent_links | Allow parent links | boolean: true/false |
| ng_slicknav_child_links | Show child links on open | boolean: true/false |
| ng_slicknav_speed | Speed menu opens/closes | integer |
| ng_slicknav_label | Label name on button | string |
| ng_slicknav_brand | Logo Image | string |
| ng_slicksearch | Logo URL | string |
| ng_slicknav_alt | Logo alt text | string |
| ng_slicknav_search | Add search field | boolean: true/false |
| ng_slicknav_closedsymbol | Close symbol | string HTML entity |
| ng_slicknav_openedsymbol | Open symbol | string HTML entity |
How to filter (examples):
Change the label on the Menu Button:
function themeprefix_slicknav_custom_label( $data ) {
$data['ng_slicknav']['ng_slicknav_label'] = 'New Label';
return $data;
}
add_filter( 'ng_slicknav_slickNavVars', 'themeprefix_slicknav_custom_label' );
Change the Closed Symbol:
function themeprefix_slicknav_custom_symbol( $data ) {
$data['ng_slicknav']['ng_slicknav_closedsymbol'] = '●' ;
return $data;
}
add_filter( 'ng_slicknav_slickNavVars', 'themeprefix_slicknav_custom_symbol' );
Conditionally change the Logo on the home page:
function themeprefix_slicknav_custom_image ( $data ) {
if( is_home() ) :
$data['ng_slicknav']['ng_slicknav_brand'] = 'http://mynewlogo.com/images/newimage.png';
return $data;
else:
return $data;
endif;
}
add_filter( 'ng_slicknav_slickNavVars', 'themeprefix_slicknav_custom_image' );
You add the filter in your functions.php file of your theme.
Gist below of all 3 examples above