-
Author
-
March 3, 2016 at 14:51 #108255bizeulabsParticipant
Hi.
I want to know how I can hide the sidebar on mobile and tablet. I have tried used wp_is_mobile() but I think I’m not doing well because I have not gotten.
can anybody help me?
Thank you.
March 3, 2016 at 15:07 #108260sharmstrModeratorThat was discussed here: https://archived.seventhqueen.com/forums/topic/mobile-sidebars-and-menu#post-73978
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
March 3, 2016 at 16:20 #108267bizeulabsParticipantThank you sharmstr
I know how to hide the sidebar with CSS but I wanted to know how to make non load the sidebar by PHP, on pages and posts.
I tried with this code in right_sidebar.php:
<?php
//create right sidebar template
if ( !wp_is_mobile() ) {
kleo_switch_layout(‘no’);
}else{
kleo_switch_layout(‘rigth’);
}
?>But it doesn´t work. And I don´t know why.
March 3, 2016 at 17:10 #108274sharmstrModeratorA few issues –
1 – Your logic is wrong/backwards. Your code is saying “if its not mobile, show full width. if it is mobile, show the sidebar”.
2 – You’ve misspelled right.
3 – According to WP you shouldn’t be using it in themes: https://codex.wordpress.org/Function_Reference/wp_is_mobile
But to answer your question, by the time it gets to right-sidebar.php its too late. You could have tested that by merely changing ‘right’ to ‘no.
If you look in the kleo_prepare_layout function, you’ll see that you can filter it. So its as simple as putting this in your child theme.
COPY CODEadd_filter( 'kleo_page_layout' , 'remove_sidebar_mobile' ); function remove_sidebar_mobile() { if ( wp_is_mobile() ) { $layout = 'no'; }else{ $layout = 'right'; } return $layout; }
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
March 3, 2016 at 17:45 #108297bizeulabsParticipantIt works perfectly.
Thanks for the explanations and resolve the doubts.
March 3, 2016 at 17:45 #108300sharmstrModeratorYou’re welcome.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.