I would like to disable my WP sidebar from within the template using something like the below, though I want to also conditionally disable it. Condition would be…when device width is max X, i.e. max-device-width: 720, or when pagination is on.
<?php if (wp_is_mobile() )
{
//do nothing
}
else
{
< ? php get_sidebar(); ? >;
}
?>
The reason for the condition…on some mobiles (tablets), the sidebar is still present, not paginated, so I want it to be shown.
You can achieve this with CSS media queries. Put something like this in your style sheet:
And the sidebar will disappear if the page is 720px or less. I’d recommend against doing the mobile check on the server side, if that’s a situation you can avoid.