Community Forums › Forums › Archived Forums › Design Tips and Tricks › Aadd a widget content area after a few pages
Tagged: widget content area
- This topic has 5 replies, 2 voices, and was last updated 8 years, 8 months ago by Marcy.
-
AuthorPosts
-
July 7, 2015 at 10:23 am #158678jimenaParticipant
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?
http://www.delpropiedades.clJuly 7, 2015 at 1:29 pm #158699MarcyParticipantYou 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 #158703jimenaParticipantThanks 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)
July 7, 2015 at 3:22 pm #158708MarcyParticipantI 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 #158745jimenaParticipantThank 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 !
July 7, 2015 at 11:31 pm #158755MarcyParticipantIf 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
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.