Disable sticky menu in mobile view


Hello,

I have one questons, hot to disable sticky menu in mobile view? Now I use that code for sticky elswhere but not in posts: What to add !wp_is_mobile() dont work or what is the right name?

if ( !is_single() || !wp_is_mobile() )
beans_add_attribute( 'beans_header','data-uk-sticky',"{top:-150, animation:'uk-animation-slide-top'}" );

Hey Boris,

While wp_is_mobile() may be use in certain scenario, that function is not really intelligent nor it is flexible. The UIkit sticky component provide you with a media parameter to control the sticky element on responsive (see how it works here). So for example if you want you sticky menu to be only stick for the devices 640px and more, then you would add media: 640 to the sticky parameters:

beans_add_attribute( 'beans_header','data-uk-sticky',"{media: 640, top:-150, animation:'uk-animation-slide-top'}" );

Hope that helps,


I must remove this `, before media and now worked fine.

Thankyou for help, now working fine.


Thanks, I updated the typo mistake. Glad to hear it is now working fine 🙂

Write a reply

Login or register to write a reply, it's free!