Support » Plugin: If Menu - Visibility control for Menu Items » Custom function and mobile

  • qwik3r


    I wrote a custom function that checks if an ACF true/false field is checked, and then selected it and added a mobile check:

    What’s happening is that the menu item is hiding on mobile regardless of if the true/false field is set to ‘true’. It doesn’t seem to be “listening” to the ‘and’ portion of your plugin.

    add_filter( 'if_menu_conditions', 'hide_mobile_nav' );
    function hide_mobile_nav( $conditions ) {
      $conditions[] = array(
        'id' =>	'hide_nav',
        'name'    =>  'Hide mobile nav', // name of the condition
        'condition' =>  function($item) {          // callback - must return TRUE or FALSE
          if ( get_field( 'hide_mobile_nav_menu' ) == '1') : 
                return get_field('hide_mobile_nav_menu');
      return $conditions;

    Can you please advise?

    • This topic was modified 2 months ago by qwik3r.
  • You must be logged in to reply to this topic.