Site logo

Archived topic

Mobile Menu float right open left

37 replies · Started by Shirley on November 17, 2019

Viewing posts 31–38 of 38

I can make the filter work - thanks for your help - I think I have it from here.

No problem :)

One more question please - Not sure if I can apply two filters within one function such as
function fiveb_update_update_mobile_media_query( ) {
if (is_front_page() || is_page( 1514 )) {
add_filter( 'generate_mobile_menu_media_query', function() {
return '(max-width: 1172)';
} );
add_filter( 'generate_not_mobile_menu_media_query', function() {
return '(min-width: 1173)';
} );
}
}

Don't think that works. Just go with this:

add_filter( 'generate_mobile_menu_media_query', function() {
    return '(max-width: 1172px)';
} );
add_filter( 'generate_not_mobile_menu_media_query', function() {
    return '(min-width: 1173px)';
} );

So modified the filter to this but still does not work. I need to filter different widths depending on page/section we are in... So far using one width but now mobile menu never appears.

add_filter( 'generate_mobile_menu_media_query', function() {
if (is_front_page() || is_page( 1514 )) {
return '(max-width: 1172)';
} else {
if (($post->ID == 2440) || (in_array(2440, $parents, TRUE))) {
return '(max-width: 1172)';
} else {
if (($post->ID == 2442) || (in_array(2442, $parents, TRUE))) {
return '(max-width: 1172)';
} else {
if (($post->ID == 2444) || (in_array(2444, $parents, TRUE)))
return '(max-width: 1172)';
}
}
}
} );

add_filter( 'generate_not_mobile_menu_media_query', function() {
if (is_front_page() || is_page( 1514 )) {
return '(min-width: 1173)';
} else {
if (($post->ID == 2440) || (in_array(2440, $parents, TRUE))) {
return '(min-width: 1173)';
} else {
if (($post->ID == 2442) || (in_array(2442, $parents, TRUE))) {
return '(min-width: 1173)';
} else {
if (($post->ID == 2444) || (in_array(2444, $parents, TRUE)))
return '(min-width: 1173)';
}
}
}
} );

I tried multiple if statements first and that did not work. Now I have (still not working)

add_filter( 'generate_mobile_menu_media_query', function() {
if (is_front_page() || is_page( 1514 )):
return '(max-width: 1172)';
elseif (($post->ID == 2440) || (in_array(2440, $parents, TRUE))):
return '(max-width: 1172)';
elseif (($post->ID == 2442) || (in_array(2442, $parents, TRUE))):
return '(max-width: 1172)';
elseif (($post->ID == 2444) || (in_array(2444, $parents, TRUE))):
return '(max-width: 1172)';
endif;
} );

add_filter( 'generate_not_mobile_menu_media_query', function() {
if (is_front_page() || is_page( 1514 )):
return '(min-width: 1173)';
elseif (($post->ID == 2440) || (in_array(2440, $parents, TRUE))):
return '(min-width: 1173)';
elseif (($post->ID == 2442) || (in_array(2442, $parents, TRUE))):
return '(min-width: 1173)';
elseif (($post->ID == 2444) || (in_array(2444, $parents, TRUE))):
return '(min-width: 1173)';
endif;
} );

At a glance, $post and $parents aren't defined in your function. Other than that, it looks like everything should work.

This archived topic is closed to new replies.