• Resolved CHomko

    (@chomko)


    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.

    https://www.ads-software.com/plugins/if-menu/

Viewing 1 replies (of 1 total)
  • Plugin Author Andrei

    (@andreiigna)

    Yep, that’s how it’s done.

    Thank you for the info ??

Viewing 1 replies (of 1 total)
  • The topic ‘How to add a conditional statement for a page’ is closed to new replies.