• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to remove a widget area from one page only

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to remove a widget area from one page only

This topic is: not resolved
  • This topic has 3 replies, 3 voices, and was last updated 6 years, 7 months ago by James Chai.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • April 2, 2017 at 7:12 pm #204193
    camille
    Member

    Hi all! I'm building a site using the Infinity Pro theme. I wanted a custom widget area to appear before the footer on all my pages and I used the Genesis Simple Hooks plugin to make it happen. It worked great.

    The problem? Now I'd like this widget area to display on every page except one. How do I remove it from one page and one page only?

    Thanks so much in advance,
    Cami

    April 2, 2017 at 11:11 pm #204199
    Brad Dalton
    Participant

    Use a conditional tag to exclude it like:

    if ( ! is_page('slug'))
    

    Or

    if ( is_page('slug'))
        return;
    

    Where slug is the page slug you want to exclude.

    Here's a full working example you can paste at the end of your child themes functions file:

    genesis_register_sidebar( array(
    	'id'          => 'new-widget',
    	'name'        => __( 'New Widget', 'domain' ),
    	'description' => __( 'Add Content Here', 'domain' ),
    ) );
    
    add_action( 'genesis_before_footer', 'your_widget' );
    function your_widget() {
    
    if ( is_page('slug') )
        return;
    
    if ( is_active_sidebar('new-widget') ) {
    
    genesis_widget_area( 'new-widget', array(
        'before' => '<div class="new-widget widget-area">',
        'after'	 => '</div>',
    		) ); 
    
      }
    
    }
    

    Swap out slug with your page slug or i.d


    Tutorials for StudioPress Themes.

    April 2, 2017 at 11:27 pm #204202
    camille
    Member

    Awesome! Thanks so much. This really helps.

    April 7, 2017 at 11:08 am #204449
    James Chai
    Member

    Alternately you can use Jetpack's 'Visibility' function. Once installed and activated one of Jetpacks features allows you activate 'Widget Visibility'.

    You can determine 'rules' to apply that will either show/hide widgets accordingly.


    Marketing, Sales and WordPress Growth Hacking http://www.smbpress.com

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble