Community Forums › Forums › Archived Forums › General Discussion › Deactivated home.php but now widget is not visible?
- This topic has 6 replies, 2 voices, and was last updated 9 years, 1 month ago by jimmyc.
-
AuthorPosts
-
March 15, 2015 at 5:53 am #144452jimmycMember
Hi,
I've deactivated the home.php but now the two widget areas below the header are not visible.
How can i get the widgets area back without activating the home.php again?
I'm using the balance theme
Cheers,
JimMarch 15, 2015 at 12:53 pm #144490ChristophMemberYou will have to take the part of the code from the home.php that adds the widgets, adjust it if you don't want to show the widgets on all pages and put it in your functions.php.
March 16, 2015 at 3:02 am #144590jimmycMemberHi,
Thank you for your advice.
Could you please help me with that. I will buy you a 5 dollar cup of coffee :D?
I have this code in my home.php
<?php
add_action( 'genesis_meta', 'balance_home_genesis_meta' );
/**
* Add widget support for homepage.
*
*/
function balance_home_genesis_meta() {if ( is_active_sidebar( 'home-featured-left' ) || is_active_sidebar( 'home-featured-right' ) ) {
add_action( 'genesis_after_header', 'balance_home_loop_helper' );
}
}/**
* Display widget content for home featured sections.
*
*/
function balance_home_loop_helper() {if ( is_active_sidebar( 'home-featured-left' ) || is_active_sidebar( 'home-featured-right' ) ) {
echo '<div id="home-featured"><div class="wrap clearfix">';
echo '<div class="home-featured-left">';
dynamic_sidebar( 'home-featured-left' );
echo '</div><!-- end .home-featured-left -->';echo '<div class="home-featured-right">';
dynamic_sidebar( 'home-featured-right' );
echo '</div><!-- end .home-featured-right -->';echo '</div><!-- end .wrap --></div><!-- end #home-featured -->';
}
}
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_grid_loop_helper' );
/** Add support for Genesis Grid Loop **/
function child_grid_loop_helper() {if ( function_exists( 'genesis_grid_loop' ) ) {
genesis_grid_loop( array(
'features' => 1,
'feature_image_size' => 0,
'feature_image_class' => 'align none post-image',
'feature_content_limit' => 0,
'grid_image_size' => 'grid',
'grid_image_class' => 'align none post-image',
'grid_content_limit' => 0,
'more' => __( 'Continue reading...', 'genesis' ),
'posts_per_page' => 5,
) );}
else {
genesis_standard_loop();
}}
genesis();
What piece of it do i need to put where in my functions.php
I don't mind if the widgets are visible on all pages except for the landing pages?
Cheers,
JimMarch 16, 2015 at 11:00 am #144636ChristophMemberLOL
That´s quite a deal you are getting 😉Remove the following from the home.php
add_action( ‘genesis_meta’, ‘balance_home_genesis_meta’ ); /** * Add widget support for homepage. * */ function balance_home_genesis_meta() { if ( is_active_sidebar( ‘home-featured-left’ ) || is_active_sidebar( ‘home-featured-right’ ) ) { add_action( ‘genesis_after_header’, ‘balance_home_loop_helper’ ); } } /** * Display widget content for home featured sections. * */ function balance_home_loop_helper() { if ( is_active_sidebar( ‘home-featured-left’ ) || is_active_sidebar( ‘home-featured-right’ ) ) { echo ‘<div id=”home-featured”><div class=”wrap clearfix”>'; echo ‘<div class=”home-featured-left”>'; dynamic_sidebar( ‘home-featured-left’ ); echo ‘</div><!– end .home-featured-left –>'; echo ‘<div class=”home-featured-right”>'; dynamic_sidebar( ‘home-featured-right’ ); echo ‘</div><!– end .home-featured-right –>'; echo ‘</div><!– end .wrap –></div><!– end #home-featured –>'; } }
Add the following at the end of the functions.php:
add_action( 'genesis_after_header', 'balance_home_loop_helper' ); /** * Display widget content for home featured sections. * */ function balance_home_loop_helper() { if ( is_active_sidebar( 'home-featured-left' ) || is_active_sidebar( 'home-featured-right' ) ) { echo '<div id="home-featured"><div class="wrap clearfix">'; echo '<div class="home-featured-left">'; dynamic_sidebar( 'home-featured-left' ); echo '</div><!– end .home-featured-left –>'; echo '<div class="home-featured-right">'; dynamic_sidebar( 'home-featured-right' ); echo '</div><!– end .home-featured-right –>'; echo '</div><!– end .wrap –></div><!– end #home-featured –>'; } }
To remove the widgets from landing pages, you have to add a line to page_landing.php.
At the bottom of the file, below the last remove_action but above genesis();
add
remove_action( 'genesis_after_header', 'balance_home_loop_helper' );
March 16, 2015 at 11:48 am #144648jimmycMemberHi,
Thank you so much.
It workes like a charm.
Instead of buying you 1 cup of coffee for 5 dollars i've bought you 2 cups for 5, total 10 dollars.
Have a great day.
Cheers,
JimMarch 16, 2015 at 12:14 pm #144650ChristophMemberHi,
glad I was able to help. 🙂
Thanks for the coffee!
Have a great day yourself.
Be well,
Christoph
March 17, 2015 at 1:34 am #144701jimmycMemberHi,
I hope it tastes great haha!
Cheers,
Jim -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.