• 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

Aadd a widget content area after a few pages

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 › Aadd a widget content area after a few pages

This topic is: not resolved

Tagged: widget content area

  • This topic has 5 replies, 2 voices, and was last updated 10 years, 4 months ago by Marcy.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • July 7, 2015 at 10:23 am #158678
    jimena
    Participant

    I need to add a widget content area after a few pages , I found this code:

    genesis_register_sidebar (array (
    'id' = > ' before- content'
    'name' = > __ ( 'Before Content' , ' wpsites ' ) ,
    'description' = > __ ('Content Displays Before Specific Content Pages . ' ' wpsites ' ) ,
    ) ) ;
    
    add_action ( ' genesis_before_content ' ' wpsites_widget_before_content ');
    wpsites_widget_before_content function ( ) {
    if ( is_page ( ' 1306 ' ) && is_active_sidebar ( ' before- content' )) {
    genesis_widget_area ( ' before- content' , array (
    ' before' = > ' < div class = " before- content" class = " widget- area" >' ,
    ' after' = > ' < / div >' ,
    ) ) ;
        }
    }

    But I can not add more pages.

    Can anyone give me a help with this?


    [URL=https://meettomy.site] Pretty Womans in your town[/URL]

    http://www.delpropiedades.cl
    July 7, 2015 at 1:29 pm #158699
    Marcy
    Participant

    You would change this section to be:

    add_action ( ' genesis_before_content ' ' wpsites_widget_before_content ');
    wpsites_widget_before_content function ( ) {
    if ( is_page ( array ( 1306, 1492, 1713 )  ) && is_active_sidebar ( ' before- content' )) {
    genesis_widget_area ( ' before- content' , array (
    ' before' = > ' < div class = " before- content" class = " widget- area" >' ,
    ' after' = > ' < / div >' ,
    ) ) ;
        }
    }

    I added an array, so that you can list the IDs of any pages you like.


    Marcy | Amethyst Website Design | Twitter

    July 7, 2015 at 2:32 pm #158703
    jimena
    Participant

    Thanks Marcy for your help , but I can not locate an error in the code, to use me back the white page of terror!!

    PHP Parse error: syntax error, unexpected '' wpsites_widget_before_conten' (T_CONSTANT_ENCAPSED_STRING)


    [URL=https://meettomy.site] Pretty Womans in your town[/URL]

    July 7, 2015 at 3:22 pm #158708
    Marcy
    Participant

    I assumed that the code you pasted was just messed up from you pasting it, and that you would have just added the array part to your clean code. If you just copied the above, it was a mess.
    Here is all of it cleaned up and tested. It should not white screen.

    genesis_register_sidebar(array (
    	'id' => 'before-content',
    	'name' => __( 'Before Content', 'wpsites' ),
    	'description' => __('Content Displays Before Specific Content Pages', 'wpsites' ),
    ) );
    
    add_action ( 'genesis_before_content', 'wpsites_widget_before_content');
    function wpsites_widget_before_content( ) {
    	if ( is_page( array( 1306, 1492, 1713 ) ) && is_active_sidebar( 'before-content' ) ) {
    		genesis_widget_area( 'before-content', array(
    			'before' => '< div class = " before-content" class = " widget-area" >',
    			'after' => '< / div >',
    		) );
    	}
    }

    Marcy | Amethyst Website Design | Twitter

    July 7, 2015 at 9:36 pm #158745
    jimena
    Participant

    Thank you very much Marcy, the code works ... But the problem now is that when I add an image to a specific page, this image is displayed on all pages.

    What I need is to add a different image for each page before the content .

    I sincerely appreciate your help !


    [URL=https://meettomy.site] Pretty Womans in your town[/URL]

    July 7, 2015 at 11:31 pm #158755
    Marcy
    Participant

    If you are using something like a text or image widget with an image in the Before Content widget area, you can insert 3 widgets - one for each page. Insert your images in each of them. Yes, you will have 3 images on each of those three pages.

    Then if you're using Jetpack, you can turn on the Widget Visibility module. For each image widget, choose to have it show only on the specific page. The Widget Visibility button is near the Save button in the widget.

    If you don't use Jetpack, then install Widget Context plugin - https://wordpress.org/plugins/widget-context/. It works just as I have described for Widget Visibility above.


    Marcy | Amethyst Website Design | Twitter

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

© 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