How to add a conditional statement for a page
-
Figured this out so I thought to post this for all to use.
EXAMPLE:
Add the If Menu selection “Maintenance Page” in the “Enable Conditional Logic” selection drop down where the page peramlink (slug) name is “maintenance” so that you can select whether to SHOW or HIDE the menu item:-
Add to the THEME FUNCTIONS.PHP file:
add_filter( 'if_menu_conditions', 'my_new_menu_conditions' ); function my_new_menu_conditions( $conditions ) { $conditions[] = array( 'name' => 'Maintenance Page', // name of the condition 'condition' => function($item) { // callback - must return TRUE or FALSE return is_page( 'maintenance' ); } ); return $conditions; }
To show or hide your page, change ‘maintenance’ to your page permalink (slug) name and change the name of the condition as appropriate.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add a conditional statement for a page’ is closed to new replies.