Community Forums › Forums › Archived Forums › Design Tips and Tricks › Left Header Widget
Tagged: Prose
- This topic has 6 replies, 3 voices, and was last updated 7 years, 3 months ago by sunnypapabear.
-
AuthorPosts
-
May 14, 2017 at 10:25 am #206414sunnypapabearMember
Okay, I've been trying to create a Header Left Widget without any luck - tried tons of different solutions. Can someone look at the below code and tell me if it should work? I put this in my Genesis Custom Code under Custom/Functions and it doesn't show up in my Appearance/Widgets. Where you see 'prose' in the code, that is just the theme I am using.
* Create Left Header Widget Function
genesis_register_sidebar( array(
'id' => 'header-left',
'name' => __( 'Header Left', 'prose' ),
'description' => __( 'Header left widget area', 'prose' ),
) );
/**
*Hook Function
*/
add_action( 'genesis_header', 'prose_left_header_widget', 11 );
function prose_left_header_widget() {
if (is_active_sidebar( 'header-left' ) ) {
genesis_widget_area( 'header-left', array(
'before' => '<div class="header-left">',
'after' => '</div>',
) );
}}May 14, 2017 at 4:57 pm #206429Brad DaltonParticipantMay 14, 2017 at 5:09 pm #206430sunnypapabearMemberYes, I got this code originally from your site, made the changes to replace wpsites with the theme name and tried it, but can't see the Widget under Appearance/Widgets?
May 15, 2017 at 9:03 am #206466sunnypapabearMemberBrad, what I actually have within my development website, http://petercruikshank.com/dev/, is the following. I didn't want to put that fully in the original Post as I just wanted to see if the code should work or not.
genesis_register_sidebar( array(
'id' => 'header-left',
'name' => __( 'Header Left', 'wpsites' ),
'description' => __( 'Header left widget area', 'wpsites' ),
) );
/**
* @author Brad Dalton WP Sites
* @example http://wp.me/p1lTu0-9VA
*/
add_action( 'genesis_header', 'wpsites_left_header_widget', 11 );
function wpsites_left_header_widget() {
if (is_active_sidebar( 'header-left' ) ) {
genesis_widget_area( 'header-left', array(
'before' => '<div class="header-left">',
'after' => '</div>',
) );
}}However when I put this in my Genesis/Custom Code under the Custom Function area, I don't see a Header Left Widget on the Appearance/Widget screen. Can you, or anyone else, tell me why the Widget is NOT showing up? Is there something else I need to do?
May 15, 2017 at 9:19 am #206468Victor FontModeratorYour code works in my local environment It might be timing issue as to when the code runs. I'm not familiar with a Genesis/Custom Code area. This does not exist on any of my sites and may have been added to yours with a plugin. Try adding your code directly to the child theme's functions.php and see if it makes a difference.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 15, 2017 at 1:02 pm #206482sunnypapabearMemberInteresting Victor, thanks. I don't normally mess with the functions.php file directly - too easy to disable the website. Instead, with at least my theme - though I though with Genesis as a whole, there is a Custom Code area where you can enter any sort of CSS or PHP code without having to touch the functions.php. This is how StudioPress recommends handling changes of this sort. I've placed a number of different sets of code there, in the past, and they've always worked fine. But for some reason, this code doesn't work for me. I've even tried just using the following simple code to register a new Widget without even trying to Hook it. Again, does not work - can't see it in Appearance/Widgets.
genesis_register_sidebar( array(
'id' => 'custom-widget',
'name' => __( 'Custom Widget', 'genesis' ),
'description' => __( 'Custom Widget Area', 'prose' ),
) );May 20, 2017 at 4:47 pm #206770sunnypapabearMemberIt took awhile and a few e-mails with Tech Support, but it turns out that, at least with the Prose Theme, if you Register a Widget in the Genesis/Custom Code/Custom Function field, it will NOT become visible in the Appearance/Widget screen. You have to do it with Simple Menus and Simple Hooks or edit the Theme Functions.php directly. Thanks to Tech Support for testing and digging into this to discover the issue with the Prose Theme.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.