Community Forums › Forums › Archived Forums › General Discussion › Can't Figure Out Registering Widget Areas
Tagged: widget registration
- This topic has 11 replies, 4 voices, and was last updated 8 years, 11 months ago by cmillar.
-
AuthorPosts
-
September 6, 2013 at 3:11 pm #61141KenTheriotMember
I just read through http://my.studiopress.com/tutorials/register-widget-area/ but am still a bit confused. It says:
"To display this widget area in your theme, you have two options. You can place the widget code directly in a template file such as home.php, where you wish to display the widget area."
On that option, would I create a template file myself? If so, where can I find instructions to do that? I am hoping to create an "After Post" widget area.
Thanks.
Ken
http://www.homebrewaudio.com/September 6, 2013 at 4:01 pm #61147KenTheriotMemberOK. I figured it out, thanks to Nick's tutorial here: http://designsbynickthegeek.com/tutorials/add-widgeted-sidebar
The answer was to put the register code and the add-action code into the child theme's Functions.php. Then style it in Style.css.
Hope that helps someone else.
Ken
May 11, 2015 at 11:37 am #151741cmillarMemberQuestion for anyone:
I followed the sample instructions in the blog which is referred to here, but I can't get the widget area to register at all.
I've tried it with the 'Simple Hooks' program, but that hasn't worked.
I'm sure I'm being very careful with the cut and paste instructions.
Is it possible that my site just can't do this sample exercise?
I'm using Parallax Pro in a multi-site situation, and trying to change one site's functions.php by adding in a new widget area, not necessarily the one in this demo.
But it seems like it should be a good model to follow?
May 11, 2015 at 12:39 pm #151746ChristophMemberHi,
just as friendly advice, you have a better chance of getting a response if you start a new topic.
The two tutorials are good for all Studiopress themes, including Parallax Pro.
There might be something going on in your functions.php that has to be addressed.Can you paste the code you are using?
(Please use the code tags - second from the right on top of the editor - to display the code)Where (in which hook) do you want the new widget area to show?
If you are using the simple hooks plugin, double check that "Execute PHP on this hook" is selected.
May 11, 2015 at 2:06 pm #151772cmillarMemberHello Christoph, and thank you very much for the help here!
(I'm like a 'home mechanic'... I can do minor oil changes and minor car adjustments, but have never rebuilt a motor from the ground up!)What I'd like to do:
- create a widget area in the 'after the header' area (so that I can place a menu plugin or other plugin)I have created a multi-site, and am working with an exact copy of Parallax Pro. The Parallax theme is also used for the main 'entry-way' website that has a link to this other site. It's all working smoothly.
I do have the 'Simple Hooks' plugin, but haven't used it before now. I thought it might make life easier. But, I'm a little confused as to what to do.
(I read somewhere that I might need to create a 'frontpage.php' or something similar?)
I need more knowledge about where to actually place the code for adding widgets and where to place the 'call to actions', when you need to use '}'s', etc. I'm sure once I know that, all should be smooth. Lot's to learn!
Sometimes, when people post examples, they include what seems to be a lot of uneccessary code lines.... which makes it very confusing to many people with less experience. (ie: instructions that are place right above the code in an editor, which makes it hard to distinguish what is needed or not needed)
Thanks for going over the code and for your ideas. Much appreciated!
Here is the original 'functions.php' code (without any of my modifications) from the site I would like to add the new widget area in:
<?php
//* Start the engine
include_once( get_template_directory() . '/lib/init.php' );//* Setup Theme
include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );//* Set Localization (do not remove)
load_child_theme_textdomain( 'parallax', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'parallax' ) );//* Add Image upload to WordPress Theme Customizer
add_action( 'customize_register', 'parallax_customizer' );
function parallax_customizer(){require_once( get_stylesheet_directory() . '/lib/customize.php' );
}
//* Include Section Image CSS
include_once( get_stylesheet_directory() . '/lib/output.php' );//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Parallax-rodeo' );
define( 'CHILD_THEME_URL', 'http://www.ramrodeotour.rossmillargroup.com' );
define( 'CHILD_THEME_VERSION', '1.2' );//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'parallax_enqueue_scripts_styles' );
function parallax_enqueue_scripts_styles() {wp_enqueue_script( 'parallax-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'parallax-google-fonts', '//fonts.googleapis.com/css?family=Montserrat|Sorts+Mill+Goudy', array(), CHILD_THEME_VERSION );}
//* Add HTML5 markup structure
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );//* Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 7 );//* Reduce the secondary navigation menu to one level depth
add_filter( 'wp_nav_menu_args', 'parallax_secondary_menu_args' );
function parallax_secondary_menu_args( $args ){if( 'secondary' != $args['theme_location'] )
return $args;$args['depth'] = 1;
return $args;}
//* Unregister layout settings
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );//* Add support for additional color styles
add_theme_support( 'genesis-style-selector', array(
'parallax-pro-blue' => __( 'Parallax Pro Blue', 'parallax' ),
'parallax-pro-green' => __( 'Parallax Pro Green', 'parallax' ),
'parallax-pro-orange' => __( 'Parallax Pro Orange', 'parallax' ),
'parallax-pro-pink' => __( 'Parallax Pro Pink', 'parallax' ),
) );//* Unregister secondary sidebar
unregister_sidebar( 'sidebar-alt' );//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 360,
'height' => 70,
'header-selector' => '.site-title a',
'header-text' => false,
) );//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'nav',
'subnav',
'footer-widgets',
'footer',
) );//* Modify the size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'parallax_author_box_gravatar' );
function parallax_author_box_gravatar( $size ) {return 176;
}
//* Modify the size of the Gravatar in the entry comments
add_filter( 'genesis_comment_list_args', 'parallax_comments_gravatar' );
function parallax_comments_gravatar( $args ) {$args['avatar_size'] = 120;
return $args;
}
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 1 );//* Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );//* Relocate after entry widget
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 );}
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'home-section-1',
'name' => __( 'Home Section 1', 'parallax' ),
'description' => __( 'This is the home section 1 section.', 'parallax' ),
) );
genesis_register_sidebar( array(
'id' => 'home-section-2',
'name' => __( 'Home Section 2', 'parallax' ),
'description' => __( 'This is the home section 2 section.', 'parallax' ),
) );
genesis_register_sidebar( array(
'id' => 'home-section-3',
'name' => __( 'Home Section 3', 'parallax' ),
'description' => __( 'This is the home section 3 section.', 'parallax' ),
) );
genesis_register_sidebar( array(
'id' => 'home-section-4',
'name' => __( 'Home Section 4', 'parallax' ),
'description' => __( 'This is the home section 4 section.', 'parallax' ),
) );
genesis_register_sidebar( array(
'id' => 'home-section-5',
'name' => __( 'Home Section 5', 'parallax' ),
'description' => __( 'This is the home section 5 section.', 'parallax' ),
) );May 11, 2015 at 3:32 pm #151792ChristophMemberThere is a lot to figure out once you start looking under the hood 😉
To me the major advantage of the simple hooks plugin is that it makes making most mistakes not as bad.
If your code has an error and you put it in the functions.php you more than likely get a "white screen of death". You will have to access the functions.php through FTP or your hosting account to fix the error before your website will be accessible again.
If you code has an error and you use the simple hooks plugin, in most cases, your code just doesn't work, but your website is still up and running.What is the code you were using that didn't work?
May 12, 2015 at 10:19 am #151867cmillarMemberHi again, and thanks.
I'll put in the code I've been trying here, which is basically just a slight change to reflect the 'after_header' widget I'd like to have.
I've been using the instructions from this fellows blog: http://designsbynickthegeek.com/tutorials/add-widgeted-sidebar
I have no way to know if if is correct information or not, but I would assume so.
Seeing as I would like to add widget area to go 'after the header', I started with this snippet:
genesis_register_sidebar( array(
'id' => 'after-header',
'name' => 'After Header',
'description' => 'This is a sidebar that goes after the header.',
) );My actions: - I pasted that code from the blog at the very bottom of my 'functions.php.' file, with the 'after-header' information.
Then, as per the blog site instructions, I pasted this in 'Simple Hooks' in the 'after_header' area:
<div class="after-header">
<?php dynamic_sidebar( 'after-header' ); ?>
</div>My actions: - I also enabled the PHP option in Simple Hooks.
If I do need to go into 'style.css', I guess the code from the blog would be a good starting point for sizing things to see what shows up?
Now, I've read where some bloggers have said I don't need to go into 'style.css' at all for this widget area?Anyways, I tried the above and didn't see any results in my theme.
Any thought and suggestions much appreciated! Don't spend all day on it!
Thanks, Cam
May 12, 2015 at 12:02 pm #151882ChristophMemberHi Cam,
thank you for providing the code.
The reason things are not working smoothly is that Nick's code is pre-HTML5.You can paste the following code at the bottom of the functions.php and forget about the simple hooks plugin.
Make sure to delete the old code because you will get a white screen if you try to declare something twice.genesis_register_sidebar( array( 'id' => 'after-header', 'name' => __( 'After Header', 'parallax' ), 'description' => __( 'This is the After Header section.', 'parallax' ), ) ); add_action( 'genesis_after_header', 'ch_after_header_widget' ); function ch_after_header_widget() { genesis_widget_area( 'after-header', array( 'before' => '<div class="after-header widget-area"><div class="wrap">', 'after' => '</div></div>', ) ); }
Without styling, the widget area will be hidden by the header.
You can target the widget area In the style.css with.after-header
. (I gave you an additional .wrap class, just in case...).after-header { margin-top: **px; }
(Replace ** with a value of your liking. From looking at it at least 40px with widget title and 80px without widget title...)
You can add all sorts of different styling to the class (text color, font size, borders, background-color, etc...)You probably have to adjust the values for margin / padding in the media queries of the style.css.
May 12, 2015 at 2:08 pm #151898cmillarMemberAh hah!
I'll try this later and will let you know how it is.... looking forward to this.
Have to leave the computer for a few hours for some of my 'other life'.Many thanks.... will get to this late tonight here or in the morning.
May 12, 2015 at 9:13 pm #151961Genesis DeveloperMemberUsing this plugin "Genesis Widget Generator" you can easily make the widget areas.
May 13, 2015 at 1:48 pm #152053cmillarMemberThis reply has been marked as private.May 20, 2015 at 9:36 pm #153039cmillarMemberThanks to all for the coding help. It's great to know.... but I'm using the "Genesis Widget Generator" with great success. Glad to report on how great it is.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.