Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add widget area above content on Streamline 2.0.1
Tagged: slider, widget, widget area
- This topic has 14 replies, 3 voices, and was last updated 12 years, 1 month ago by
swansonwc.
-
AuthorPosts
-
March 7, 2013 at 12:56 pm #24822
swansonwc
MemberHi,
I'm moving my wife's site to WordPress using the Streamline child theme. I'd like to be able to add an image slider above the content, and have it look similar to Streamline 1.0.1 - I did another site with that theme a little over a year ago http://motivational-speakers-review.com.
I've been digging through the tutorials and the forum, but I'm not getting any result. I've added the following code to the functions.php page (in the Streamline child directory):
genesis_register_sidebar( array(
'id' => 'home-page-slider',
'name' => __( 'Home Page Slider', 'streamline' ),
'description' => __( 'This is a widget area that holds a picture slideshow on the homepage', 'streamline' ),
) );This has given me a new widget area in the admin panel.
From one of Brad Dalton's answers in the forum, I added this code to my home.php file:
/**
* Display image slider on home page above content.
*
*/
add_action( 'genesis_before_content', 'child_before_content');
function child_before_content() {
if ( is_home() ) {
echo '<div id="home-page-slider">';
dynamic_sidebar( 'home-page-slider' );
echo '</div><!-- end #home-page-slider -->';
}
}I added a widget to the new area, but it doesn't show up. I'm not a php or WordPress programmer, so I'm just hacking here. I'd appreciate any advice on where I'm going wrong. The site I'm working on is: http://75.103.78.29/~kellyswa/
On the motivational-speakers-review site I used the dynamic content gallery plugin. I noticed that there are several other image slider plugins now available for the Genesis framework. Are there any advantages to the other sliders?
Best regards,
Bill
March 7, 2013 at 6:35 pm #24903Brad Dalton
ParticipantHi Bill
1. Sorry to hear you have problems with the code.
That code has been copied and pasted incorrectly resulting in errors.
Please refer to FAQ No.5 for help on how to post code snippets in this forum http://www.studiopress.community/faq/
Its best practice to copy the raw version of the code and paste it into your functions.php file using a text editor like Notepad++ otherwise you may get an error.
Exactly which genesis_hook do you want to use? http://genesistutorials.com/visual-hook-guide/
Home page only or all pages? Any conditional tags you want to use with the code http://codex.wordpress.org/Conditional_Tags
Try the raw version of this code https://gist.github.com/braddalton/5060622
or this https://gist.github.com/braddalton/5047932
or this http://pastebin.com/7S31KHym
I have tested all these locally using the Streamline theme and they all work perfectly.
2. I suggest you use the Genesis Responsive Slider plugin or Easing Slider.
Please let me know if you have any further problems you need help with.
Thanks.
March 7, 2013 at 8:32 pm #24919swansonwc
MemberBrad,
That's outstanding. Thank you!
Yeah, I figured I had put the code in wrong. I'll use your suggestions in the morning and get back with you on the results.
Best regards,
Bill
March 7, 2013 at 8:52 pm #24923micki
ParticipantHi, Following this and I am confused as to where I would put the conditional tags to have a widget before content be only on the home page.
Do I add it to this and how exactly? I am challenged this way :).
In child functions:
add_action( 'genesis_before_loop', 'child_before_posts_sidebar' );
/** Loads a new sidebar before the posts in the #content */
function child_before_posts_sidebar() {echo '<div class="before-posts-sidebar">';
dynamic_sidebar( 'before-posts-sidebar' );
echo '</div>';}
thanks for any help you can provide.
March 7, 2013 at 9:02 pm #24925Brad Dalton
ParticipantPlace this code at the end of your child thems functions.php file https://gist.github.com/braddalton/5060622
Copy the raw code version and paste it in your child themes functions.php file using a text editor like Notepad++
March 7, 2013 at 9:41 pm #24927micki
ParticipantThank you! Just wanting to make sure I have this correct before I add it.
add_action( 'genesis_before_loop', 'child_before_posts_sidebar' );
/** Loads a new sidebar before the posts in the #content */
function child_before_posts_sidebar() {
if ( is_home() ) {echo '<div class="before-posts-sidebar">';
dynamic_sidebar( 'before-posts-sidebar' );
echo '</div>';
}}
basically I am just adding the if ( is_home() )
March 8, 2013 at 12:27 am #24941Brad Dalton
ParticipantMarch 8, 2013 at 1:27 am #24950micki
ParticipantI probably need to clarify that I am not using it for a slider, I am using it for text only. I apologize for not being more specific. Here is what is working BUT it is on all pages and I only need it for the home page. Maybe I should have opened a new thread... thought it was along the same vein...
genesis_register_sidebar( array(
'id' => 'before-posts-sidebar',
'name' => 'Before Posts',
'description' => 'This is a sidebar that goes before the posts in the #content.',
) );add_action( 'genesis_before_loop', 'child_before_posts_sidebar' );
/** Loads a new sidebar before the posts in the #content */
function child_before_posts_sidebar() {echo '<div class="before-posts-sidebar">';
dynamic_sidebar( 'before-posts-sidebar' );
echo '</div>';}
and I added what I think is the correct code for only the home page to:
add_action( 'genesis_before_loop', 'child_before_posts_sidebar' );
/** Loads a new sidebar before the posts in the #content */
function child_before_posts_sidebar() {
if ( is_home() ) {echo '<div class="before-posts-sidebar">';
dynamic_sidebar( 'before-posts-sidebar' );
echo '</div>';
}}
Thank you for your help.
March 8, 2013 at 1:29 am #24951micki
Participantoh and sorry, forgot to add, this is a different theme then Streamline.
March 8, 2013 at 1:41 am #24953Brad Dalton
ParticipantMicki
You didn't copy and paste the raw code from this link https://gist.github.com/braddalton/5060622
The code you have posted is Not the same.
It doesn't matter which theme you are using unless its Prose. This code will work on most themes.
What theme are you using?
Where did you get that code you have posted?
By the way, please read FAQ No.5 about posting code properly on these forums. Thanks.
March 8, 2013 at 11:20 am #25014micki
ParticipantI got the code from : http://designsbynickthegeek.com/tutorials/add-widgeted-sidebar
See, you can tell how novice I am at this stuff... seeing slider and magazine in the code doesn't make sense to me :).
I am using the MomPrenuer theme.
Thanks!
March 8, 2013 at 1:56 pm #25038micki
ParticipantOk, adding the if ( is_home() )... to the code i am working with worked great! Sorry if I highjacked this thread, i answered my own question, thanks for your input and help.
March 11, 2013 at 12:58 pm #25489swansonwc
MemberHi Brad,
I've had a chance to implement your code, and the slider is working well -- except that it is on all pages. The conditional code to limit the slider to the home page didn't work, because I changed the home page to a static page using the 'sample page'. The post ID for the sample page is 2. Can I use the ID number in an if statement to limit the slider to the home page?
Best regards,
Bill
March 11, 2013 at 7:46 pm #25553Brad Dalton
ParticipantHi Bill.
Yes you can.
genesis_register_sidebar( array( 'id' => 'home-custom', 'name' => __( 'Home Custom', 'streamline' ), 'description' => __( 'This is the custom widget area for your homepage.', 'streamline' ), ) ); add_action( 'genesis_before_content_sidebar_wrap', 'child_before_content'); function child_before_content() { if ( is_page(2) ) { echo '<div id="home-custom">'; dynamic_sidebar( 'home-custom' ); echo '</div><!-- end #home-custom -->'; } }
March 12, 2013 at 6:59 am #25633swansonwc
MemberBrad,
Worked perfectly. Thank you.
Best regards,
Bill
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.