Community Forums › Forums › Archived Forums › General Discussion › Add/Register new widget in CafePro?
- This topic has 6 replies, 3 voices, and was last updated 9 years, 1 month ago by lifanovsky.
-
AuthorPosts
-
February 28, 2015 at 5:07 pm #142683bataladcMember
Hi, I am trying to add a new widget after Page 1 on my site. After reading some similar posts in the forum, I managed to register the code to function.php and add it to front-page.php. I see the new widget in the Widgets area, but I can't see the widget or its contents on the page. Should I be adding any other code to these files? Any help is greatly appreciated.
Added this to functions:
genesis_register_sidebar( array(
'id' => 'front-page-Newsletter',
'name' => __( 'Front Page Newsletter', 'cafe' ),
'description' => __( 'This is the Front Page Newsletter section.', 'cafe' ),
) );Added this to front-page:
genesis_widget_area( 'front-page-Newsletter', array(
http://www.batalawashington.com/new-site
'before' => '<div id="front-page-Newsletter" class="front-page-Newsletter solid-section"><div class="widget-area ' . cafe_widget_area_class( 'front-page-Newsletter' ) . '"><div class="wrap">',
'after' => '</div></div></div>',
) );March 1, 2015 at 6:07 am #142719Victor FontModeratorI don't know why, but if you change front-page-Newsletter to front-page-5 it works.
You also need to adjust the if statement at the top of the page to:
is_active_sidebar( 'front-page-1' ) || is_active_sidebar( 'front-page-2' ) || is_active_sidebar( 'front-page-3' ) || is_active_sidebar( 'front-page-4' || is_active_sidebar( 'front-page-5' ) ) )
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 5, 2015 at 11:00 am #143340bataladcMemberThanks for your replay! I just realized that when I added the Newsletter widget at first, it actually replaced widget #4. So I only see the widgets for Front Page1, Newsletter, Front Page2, and Front Page3. Widget #4 isn't there anymore.
I tried entering #5 instead of Newsletter all throughout the files but it didn't work either. I only saw the 4 default widgets.
What am I doing wrong?
March 5, 2015 at 6:38 pm #143390Victor FontModeratorFirst, make sure your functions.php is defining all five widget areas correctly:
//* Register widget areas genesis_register_sidebar( array( 'id' => 'before-header', 'name' => __( 'Before Header', 'cafe' ), 'description' => __( 'This is the section before the header.', 'cafe' ), ) ); genesis_register_sidebar( array( 'id' => 'front-page-1', 'name' => __( 'Front Page 1', 'cafe' ), 'description' => __( 'This is the Front Page 1 section.', 'cafe' ), ) ); genesis_register_sidebar( array( 'id' => 'front-page-2', 'name' => __( 'Front Page 2', 'cafe' ), 'description' => __( 'This is the Front Page 2 section.', 'cafe' ), ) ); genesis_register_sidebar( array( 'id' => 'front-page-3', 'name' => __( 'Front Page 3', 'cafe' ), 'description' => __( 'This is the Front Page 3 section.', 'cafe' ), ) ); genesis_register_sidebar( array( 'id' => 'front-page-4', 'name' => __( 'Front Page 4', 'cafe' ), 'description' => __( 'This is the Front Page 4 section.', 'cafe' ), ) ); genesis_register_sidebar( array( 'id' => 'front-page-5', 'name' => __( 'Front Page Newsletter', 'cafe' ), 'description' => __( 'This is the Front Page Newsletter section.', 'cafe' ), ) );
Next, make sure the front-page has the right code in the function:
function cafe_homepage_widgets() { genesis_widget_area( 'front-page-1', array( 'before' => '<div id="front-page-1" class="front-page-1 solid-section"><div class="widget-area ' . cafe_widget_area_class( 'front-page-1' ) . '"><div class="wrap">', 'after' => '</div></div></div>', ) ); genesis_widget_area( 'front-page-2', array( 'before' => '<div id="front-page-2" class="front-page-2 image-section"><div class="widget-area ' . cafe_widget_area_class( 'front-page-2' ) . '"><div class="wrap">', 'after' => '</div></div></div>', ) ); genesis_widget_area( 'front-page-3', array( 'before' => '<div id="front-page-3" class="front-page-3 solid-section"><div class="widget-area ' . cafe_widget_area_class( 'front-page-3' ) . '"><div class="wrap">', 'after' => '</div></div></div>', ) ); genesis_widget_area( 'front-page-4', array( 'before' => '<div id="front-page-4" class="front-page-4 image-section"><div class="widget-area ' . cafe_widget_area_class( 'front-page-4' ) . '"><div class="wrap">', 'after' => '</div></div></div>', ) ); genesis_widget_area( 'front-page-5', array( 'before' => '<div id="front-page-5" class="front-page-5 solid-section"><div class="widget-area ' . cafe_widget_area_class( 'front-page-5' ) . '"><div class="wrap">', 'after' => '</div></div></div>', ) ); }
Last, make sure the if statement at the top of front-page is correct:
if ( is_active_sidebar( 'front-page-1' ) || is_active_sidebar( 'front-page-2' ) || is_active_sidebar( 'front-page-3' ) || is_active_sidebar( 'front-page-4' || is_active_sidebar( 'front-page-5' ) ) ) {
I've made these changes to a copy of CafePro in my development environment. I know they work.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 8, 2015 at 3:12 pm #143699bataladcMemberHi Victor, thanks so much for your help, but for some reason it isn't working for me. I deleted all my code and I copied the code you posted into the pages and I still see only Before header and the 4 pages. I don't see the widget #5. Its so weird because when I add and register the page "Newsletter" code after the front page #1 I see the widget there, but can't see the contents on the page. It seems like I can only have 4 widgets there plus the before header. When I add a second widget after #1 my widget # 4 disappears. I am not sure whats going on. I thought it would be simpler to add an extra widget to this site. Thanks again for your help!
March 8, 2015 at 3:33 pm #143703bataladcMemberHi David, it works! I am feeling so stupid right now. Ok, on my widget area I was missing widget #5 because it was actually positioned on the other column. Duh... I was refreshing the page and only seeing #4. Thanks so ,much for you help!
September 14, 2015 at 2:10 pm #165470lifanovskyMemberThank you guys, this thread helped me a lot!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.