Created
June 3, 2015 18:00
-
-
Save MichaelConte/99f419cb3c0a844a28ba to your computer and use it in GitHub Desktop.
How to Show or Hide Widgets on Specific Pages without Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'widget_display_callback', 'hide_widget_pages', 10, 3 ); | |
function hide_widget_pages( $instance, $widget, $args ) { | |
if ( $widget->id_base == 'pages' ) { // change 'pages' to widget name | |
if ( !is_page( 'contact' ) ) { // change page name | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment