- This topic has 37 replies, 3 voices, and was last updated 4 years, 5 months ago by Tom.
-
AuthorPosts
-
November 17, 2019 at 7:21 pm #1066007Shirley
I can make the filter work – thanks for your help – I think I have it from here.
November 17, 2019 at 7:44 pm #1066014LeoStaffCustomer SupportNo problem 🙂
November 18, 2019 at 5:43 am #1066342ShirleyOne 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)’;
} );
}
}November 18, 2019 at 8:38 am #1066623LeoStaffCustomer SupportDon’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)'; } );
November 18, 2019 at 11:46 am #1066785ShirleySo 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)’;
}
}
}
} );November 18, 2019 at 11:51 am #1066789LeoStaffCustomer SupportLooks like the wrong syntax.
You can either use multiple
if
statements or just use theelseif
suggested here:
https://www.php.net/manual/en/control-structures.elseif.php
https://www.w3schools.com/php/php_if_else.aspNovember 18, 2019 at 12:05 pm #1066796ShirleyI 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;
} );November 18, 2019 at 3:39 pm #1066930TomLead DeveloperLead DeveloperAt a glance,
$post
and$parents
aren’t defined in your function. Other than that, it looks like everything should work. -
AuthorPosts
- You must be logged in to reply to this topic.