Skip to content

Instantly share code, notes, and snippets.

@humbertosilva
Last active November 2, 2018 14:38
Show Gist options
  • Save humbertosilva/b9effafe705236572e346725f131d92a to your computer and use it in GitHub Desktop.
Save humbertosilva/b9effafe705236572e346725f131d92a to your computer and use it in GitHub Desktop.
Remove widgets from sidebar on article view to make sidebar not bigger than content.
// best placement before </body> on footer.php
<script type="text/javascript">
jQuery(document).ready(function(){
function shrinkSidebar(){
if ( jQuery('.td-main-sidebar').height() > jQuery('.td-main-content').height() ) {
jQuery('.td-main-sidebar > .td-ss-main-sidebar').find('div:first').siblings().last().remove();
if ( jQuery('.td-main-sidebar').height() > jQuery('.td-main-content').height() ) {
shrinkSidebar();
}
}
}
if ( jQuery('body.single-post').length > 0 ) {
shrinkSidebar();
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment