Community Forums › Forums › Archived Forums › Design Tips and Tricks › HTML5 Code to add extra widget – Can Someone Please Check it?
Tagged: Add widget to home page, html5, Outreach Pro
- This topic has 28 replies, 2 voices, and was last updated 10 years, 9 months ago by nutsandbolts.
-
AuthorPosts
-
January 5, 2014 at 9:37 pm #83480palpatineMember
Hello All,
I'm trying to add a widget to the Outreach Pro theme, for the Home page ONLY, right under the bottom 4 widgets (called home-bottom).
From all the tutorials, I've compiled this code below. Will this work?:
Code to create new Home page widget in functions.php:
genesis_register_sidebar( array(
'id' => 'home-content',
'name' => __( 'Home - Content', 'outreach' ),
'description' => __( 'This is the main content section of the Home page.', 'outreach' ),
) );Code to add to front-page.php:
//* Add home content widget
add_action( 'genesis_before_footer', 'outreach_home_content_widget' );Code to add to Outreach Pro style.css:
.home-content .widget {
margin: 0;
padding: 0 40px 40px;
padding: 0 4rem 4rem;
}.home-content .widget {
padding-top: 40px;
padding-top: 4rem;
}I just want an area to post some unique text content on the Home page, so if there's something that I'm leaving out, I'd really appreciate someone correcting me.
Also, I've never done anything in HTML5, so I'd really like someone's expert opinion before I just paste this code on my site.
One more thing...
The home-bottom (default home page widgets) already use the 'genesis_before_footer' hook, so how will the theme know to execute this code below the other code that is already there with the same hook?
I hope I'm being clear here, but if anyone has any recommendations or questions, I'd really appreciate it.
Thanks,
AaronJanuary 5, 2014 at 9:43 pm #83482nutsandboltsMemberLooks good, except you need a little more in front-page.php. Something like this:
//* Add home content widget add_action( 'genesis_before_footer', 'outreach_home_content_widget', 11 ); function outreach_home_content_widget() { genesis_widget_area( 'home-content', array( 'before' => '<div class="home-content widget-area">', 'after' => '</div>', ) ); }
That 11 that I added to your
add_action
line *should* prioritize the new widget area below home-bottom, but if it doesn't, try increasing or decreasing the number (depending on where it shows up). If you run into trouble, update here and I'll do my best to help.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 10:41 pm #83488palpatineMemberHi Andrea,
Thank you so much for your assistance.
Unfortunately, it's not working 🙁
I did try different numbers, other than 11, but nothing shows up where the widget is supposed to be. It's like I didn't add an extra widget at all. There is a space between the , and the 11, and a space afterwards. Not sure if that matters or not, but I used the exact code that is mentioned above. I just cut and pasted.
Any other ideas?
Thanks,
AaronJanuary 5, 2014 at 10:45 pm #83489nutsandboltsMemberHold on... Let me throw Outreach Pro on a test site and I'll see why it's not happy. 🙂
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 10:49 pm #83491palpatineMemberYou're Awesome! I can send you a link to the site I'm working on if that makes things easier. Can we PM in this forum? Or, do you want to send me your email?
Either way, I'm eagerly waiting to hear what you come up with.
Thanks Again,
AaronJanuary 5, 2014 at 10:51 pm #83492palpatineMemberI'll bet it has to go under that if statement in front-page.php. Just a guess, I really have no idea.
January 5, 2014 at 10:52 pm #83493nutsandboltsMemberOkay, assuming you haven't customized anything else in front-page.php, this will work (this is a whole new front-page.php for you to upload in place of your current one) - https://www.dropbox.com/s/wirn9rlt6kouoat/front-page.php
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 10:57 pm #83494palpatineMemberWell, without just replacing my front-page.php with this, it looks like you did this, under the if statement:
//* Add home content widgets
add_action( 'genesis_before_footer', 'outreach_home_content_widgets' );I noticed that widgets is now plural, instead of singular as we had it before. Is that going to make a difference?
Also, was there a way to prioritize this widget to show up after the home-bottom widgets?
Thanks,
AaronJanuary 5, 2014 at 11:00 pm #83496nutsandboltsMemberI did that, but I also added to the if statement and added the function for the widget area at the bottom. Which is why it's just easier to replace the whole thing - that way nothing gets left out.
The home bottom area already has a priority of 1, so there's no need to prioritize the home content area - it will automatically display after home bottom. I've got it working on a test site here (albeit with no CSS): http://newjohn.nutsandboltsmedia.com/
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:01 pm #83497nutsandboltsMemberAnd of course I said that and just did something that caused it to stop displaying... Hold on.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:04 pm #83498palpatineMemberOkay, no worries. Standing by...
January 5, 2014 at 11:04 pm #83499nutsandboltsMemberAh, my bad. It does need priority because of the subfooter left and right areas - forgot about those. (It's showing in black between the home bottom and subfooter areas right now - no CSS as I said.)
//* Add home content widgets add_action( 'genesis_before_footer', 'outreach_home_content_widgets', 2 );
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:07 pm #83501nutsandboltsMemberNew link to front-page.php: https://www.dropbox.com/s/f0c0sl5eq3c38me/front-page.php
Widget vs. widget doesn't matter as long as the usage is consistent in both places. If one differs from the other, you'll break your site.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:09 pm #83502palpatineMemberWhen I just added that small piece of code above, I get the black box as well, but there's hidden text in it that says:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'outreach_home_content_widgets' was given in /home2/ocr/public_html/wp-includes/plugin.php on line 42
January 5, 2014 at 11:10 pm #83503nutsandboltsMemberThat's why I gave you the whole thing and said it would be easier to replace the entire file. 😀
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:12 pm #83504palpatineMemberWhoops, nevermind, I added that other code at the bottom of the page and it works good. Thanks.
Now, I just need to figure out how to make the background white (like home-bottom) and the text black.
Got a quick fix for me?
January 5, 2014 at 11:13 pm #83505nutsandboltsMemberCSS:
#home-content { background-color: #fff; color: #000; }
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:15 pm #83507palpatineMemberThanks sooooo much. I'll add that to the stylesheet.
I really appreciate your assistance Andrea. Have a good one.
-Aaron
January 5, 2014 at 11:15 pm #83508nutsandboltsMemberNo problem! Sorry for the confusion - that's what happens when I work too late at night.
I'm going to mark this topic as resolved but feel free to open a new one if you need more help. 🙂
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 5, 2014 at 11:17 pm #83509palpatineMemberYou got it.
But, before I let you go... I noticed that this looks different than what's in the current stylesheet. Does this CSS go in the front-page, or the stylesheet?
Thanks,
Aaron -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.