• 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

New Widget That Shows On Pages Only and Another That Shows on Posts 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 › New Widget That Shows On Pages Only and Another That Shows on Posts Only

This topic is: resolved

Tagged: Sidebar, widget

  • This topic has 2 replies, 3 voices, and was last updated 11 years ago by DTHkelly.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 12, 2015 at 11:18 am #137200
    Kim Turcotte
    Member

    Hi,

    I am looking to have a sidebar widget appear just under the header. The thing is, I want to be able to control the content for this area on the home page, on all Pages and on all Posts.

    I've created one sidebar that I have only appearing on the home page and it is working fine.

    Then, I've created another that shows everywhere but the home page, this also works fine, but on this second one, I would like to select/filter it to show only on pages, then I want to copy it to create a third and change the filter so that it only appears on posts.

    I am unclear of what coding to use to filter it only for pages and only for posts.

    Here is the code that I have for the widget that is currently appearing on all pages/posts except the home page:

    //* Add the inside page banner and exclude on homepage
    add_action( 'genesis_after_header', 'child_after_header_opt_in_sidebar' );
    
    /** Loads a new sidebar after the header */
    function child_after_header_opt_in_sidebar() {
        echo '<div class="after-header-opt-in">';
    if ( !is_home() && !is_front_page() )
            dynamic_sidebar( 'after-header-opt-in' );
        echo '</div>';
     }
    

    Any help with the filter code would be greatly appreciated!

    Thanks
    Kim

    http://www.goddesslifestyleplan.com/magic/
    January 13, 2015 at 3:04 am #137303
    Brad Dalton
    Participant

    Use conditional tags

    http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page


    Tutorials for StudioPress Themes.

    January 13, 2015 at 8:30 am #137312
    DTHkelly
    Member

    This tutorial includes conditional tags:
    http://www.carriedils.com/add-widget-area-below-nav/

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 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

© 2026 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