• 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

Widget Content Showing in Content Archives

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 › General Discussion › Widget Content Showing in Content Archives

This topic is: resolved

Tagged: content archives, hooks, widgets

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 4 months ago by Kip.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • March 10, 2015 at 9:35 am #143916
    Kip
    Member

    First I'd like to apologise if I'm not using the right terminology to explain what I'm trying to do (and what's going wrong). I'm new to Genesis and my grasp of php is, at best, very basic.

    I've created a hook to add a widget area before the entry content on single post pages and it works fine, but the problem is it's displaying that content on the content archives pages as well.

    /** Add sidebar at the top of single posts **/
    genesis_register_sidebar( array(
    'id'        => 'single-post-header',
    'name'      => 'Single Post Header',
    'description'   => 'This is a sidebar that goes before content on single posts',) );
    add_action( 'genesis_before_entry_content', 'before_single_post_widget' );
    
    /** Loads a new sidebar before single posts */
    function before_single_post_widget() {
    if ( is_singular( 'post' ) )
         echo '<div class="single-post-header">';
    	 dynamic_sidebar( 'single-post-header' );
    	 echo '</div>'; 
    	 }

    Whatever widgets I add to that sidebar appear as desired in single posts, but also appear on the content archives pages, even if I limit the characters to 1 theme customisation settings. Any tips on how to keep the widgets from displaying everywhere but in single posts will be greatly appreciated!

    March 11, 2015 at 4:58 am #143991
    Victor Font
    Moderator

    You could possible test for the page template being displayed with is_page_template() (http://codex.wordpress.org/Function_Reference/is_page_template).

    if ( is_singular( 'post' ) && is_page_template( 'single') )


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    March 11, 2015 at 9:01 am #144009
    Kip
    Member

    That worked exactly how I needed it to if I use is_singular. I tried something similar before with no luck, but I'm happy I was at least on the right track. Maybe a formatting issue I'm not aware of or something. Anyway, thanks so much for your help!

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Widget Content Showing in Content Archives’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

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