Community Forums › Forums › Archived Forums › General Discussion › Created new widget area but not appearing on site
Tagged: add widgets, New Widget Area, widgets
- This topic has 6 replies, 3 voices, and was last updated 7 years, 10 months ago by Nurdit.
-
AuthorPosts
-
February 5, 2017 at 3:11 pm #200599bill scheiderMember
I'm attempting to create a new widget area holding three widgets after the content in my child theme.
The widgets appear in the dashboard - they've been created - but don't show up on the front end.
Can someone take a look at the code from my functions file and tell me what I may be doing wrong?//* Register widget area after content genesis_register_sidebar( array( 'id' => 'after-content1', 'name' => __( 'After Content 1', 'genesis' ), 'description' => __( 'Custom Widget Area', 'childtheme' ), ) ); genesis_register_sidebar( array( 'id' => 'after-content2', 'name' => __( 'After Content 2', 'genesis' ), 'description' => __( 'Custom Widget Area', 'childtheme' ), ) ); genesis_register_sidebar( array( 'id' => 'after-content3', 'name' => __( 'After Content 3', 'genesis' ), 'description' => __( 'Custom Widget Area', 'childtheme' ), ) ); add_action( 'genesis_after_content', 'new_genesis_widget_area' ); function new_genesis_widget_area() { genesis_widget_area( 'genesis_after_content', array( 'before' => '<div class=“after-content widget-area">', 'after' => '</div>', ) ); }
Thanks very much
http://www.syntonicmicrowave.com/products/synthesizersnew/February 5, 2017 at 4:46 pm #200605Victor FontModeratorThe hook in which you display a widget area is not a widget area in and of itself. In your code, you've created 3 new widget areas, after-content1, after-content2, and after-content3. In the genesis_widget_area, you are trying to display a widget area named genesis_after_content. If you want to display a new widget area in the after content hook, you need to create 1 widget area.
genesis_register_sidebar( array( 'id' => 'after-content', 'name' => __( 'After Content 1', 'genesis' ), 'description' => __( 'Custom Widget Area', 'childtheme' ), ) ); add_action( 'genesis_after_content', 'new_genesis_widget_area' ); function new_genesis_widget_area() { genesis_widget_area( 'after-content', array( 'before' => '<div class=“after-content widget-area">', 'after' => '</div>', ) ); }
Also, change 'childtheme' to the child theme's text domain.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?February 5, 2017 at 8:05 pm #200613bill scheiderMemberThank you for your response, Victor.
I did change my functions.php from my code above to the code you generously provided. However, it hasn't resolved the issue! The widget area is still not being populated.
change 'childtheme' to the child theme's text domain
By changing 'childtheme' do you mean to change it to the name I've given my child theme, ie, 'syntonic'? I did that also to no avail.
The page url again is http://www.syntonicmicrowave.com/products/synthesizersnew/ if that helps at all.
Thanks again
February 6, 2017 at 6:52 am #200627Victor FontModeratorYour site is using the Genesis Sample theme. The child text domain is 'genesis-sample'. I tested the code in my local environment using the Genesis Sample theme. The code works fine, but the widget area is hidden behind the content. You need to apply CSS to the after-content widget area before you can see it in it's proper location. Here's the revised code and starter CSS:
genesis_register_sidebar( array( 'id' => 'after-content', 'name' => __( 'After Content', 'genesis' ), 'description' => __( 'Custom Widget Area', 'genesis-sample' ), ) ); add_action( 'genesis_after_content', 'new_genesis_widget_area' ); function new_genesis_widget_area() { genesis_widget_area( 'after-content', array( 'before' => '<div class="after-content widget-area">', 'after' => '</div>', ) ); }
.after-content.widget-area { clear: both; }
In reviewing this post, I also just noticed that you have a curly quote at the beginning of after-content widget-area. Curly quotes will break PHP every time. You always have to use straight quotes. You editor may be applying curly quotes by default.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 10, 2017 at 10:06 am #202835NurditMemberHi Victor,
I have used your code in your post above (in my child functions.php) and I have getting nothing in the widgets dashboard or showing on my front-page.php (within my child theme called genesis-sample).
Any help would be great!
March 10, 2017 at 12:27 pm #202837Victor FontModeratorThe code I gave you works. I tested it in my local environment with the Genesis Sample theme. I can't help you after you copy it. Perhaps your text editor converted the characters to html entities as they appear in your first post. The code in your original post would never work.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 10, 2017 at 2:52 pm #202849NurditMemberDisregard, all sorted thanks mate
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.