Community Forums › Forums › Archived Forums › General Discussion › Removing Loop on Home Page
Tagged: Loop Removal, widgets
- This topic has 3 replies, 2 voices, and was last updated 10 years, 8 months ago by brace1.
-
AuthorPosts
-
August 22, 2013 at 6:30 am #58164brace1Member
Hi everyone,
I have created a widgetized home page (straight out of functions.php) that powers my seven-site network. You can see an example, (http://www.lasallehoops.com). I am running a customized sixteen-nine theme.
The problem is that no matter how hard I try, I cannot remove the loop for the home page. I've tried simple things like
if (is_home()) { remove_action( 'genesis_loop', 'genesis_do_loop' ); }
As well as much more complex solutions. I've attached the widget part of my functions.php below:
/** Register Top Featured widget area **/ genesis_register_sidebar( array( 'id' => 'top-featured', 'name' => __( 'Top Featured Widget', 'sixteen-nine' ), 'description' => __( 'This is the Top Featured widget area which outputs on your blog page.', 'sixteen-nine' ), ) ); add_action( 'genesis_before_loop', 'top_featured', 5 ); function top_featured() { if ( is_home() && is_active_sidebar( 'top-featured' ) ) { echo '<div class="top-featured">'; dynamic_sidebar( 'top-featured' ); echo '</div><!-- end .top-featured -->'; }} /** Register Second Featured widget area **/ genesis_register_sidebar( array( 'id' => 'second-featured', 'name' => __( 'Second Featured Widget', 'sixteen-nine' ), 'description' => __( 'This is the Second Featured widget area which outputs on your blog page.', 'sixteen-nine' ), ) ); add_action( 'genesis_before_loop', 'second_featured', 5 ); function second_featured() { if ( is_home() && is_active_sidebar( 'second-featured' ) ) { echo '<div class="second-featured">'; dynamic_sidebar( 'second-featured' ); echo '</div><!-- end .second-featured -->'; }} /** Register Bottom Featured widget area **/ genesis_register_sidebar( array( 'id' => 'bottom-featured', 'name' => __( 'Bottom Featured Widget', 'sixteen-nine' ), 'description' => __( 'This is the Bottom Featured widget area which outputs on your blog page.', 'sixteen-nine' ), ) ); add_action( 'genesis_before_loop', 'bottom_featured', 5 ); function bottom_featured() { if ( is_home() && is_active_sidebar( 'bottom-featured' ) ) { echo '<div class="bottom-featured">'; dynamic_sidebar( 'bottom-featured' ); echo '</div><!-- end .bottom-featured -->'; }}
The solutions I've tried either don't work or remove the loop for everything. The problem with the loop is that I am getting a single duplicate post under my widgets from the loop. I thought I was getting good enough to do this but clearly was wrong.
Thanks for any help.
~joe
http://www.lasallehoops.comAugust 22, 2013 at 11:01 am #58224RobinMemberWell, I could be wrong here, but what I see is that you're removing the loop but then adding actions before the loop. You want to remove your loop and do a custom loop.
I don't know if it's best practices, or just another way of doing things, or what, but usually what I've done and seen done is to register your widget areas in your functions and then do your custom loop in a home.php or front-page.php. That way your work to add the widget areas to your home page don't have to have the is_home conditional.
Hope that helps get you started--
I do the best I can with what I’ve got. (say hey on twitter)
August 22, 2013 at 3:28 pm #58277brace1MemberYeah, I built it a different way, but I think that is where we are heading.
Thanks.
August 22, 2013 at 4:22 pm #58294brace1MemberSo this is what I built, but there is an error somewhere:
<?php remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'child_home_loop_helper' ); // Execute custom child loop function child_home_loop_helper() { ?> <div class=“top-featured”> <?php if (!dynamic_sidebar(‘Top Featured’)) : ?> <div class="widget"> <div class="wrap"> <p><?php _e("This is a widgeted area which is called Featured Top.”, 'genesis'); ?></p> </div><!-- end .wrap --> </div><!-- end .widget --> <?php endif; ?> </div><!-- end .top-featured --> <div class=“second-featured”> <?php if (!dynamic_sidebar(‘Second Featured’)) : ?> <div class="widget"> <div class="wrap"> <p><?php _e("This is a widgeted area which is called Second Featured.”, 'genesis'); ?></p> </div><!-- end .wrap --> </div><!-- end .widget --> <?php endif; ?> </div><!-- end .second-featured--> <div class=“bottom-featured”> <?php if (!dynamic_sidebar(‘Bottom Featured’)) : ?> <div class="widget"> <div class="wrap"> <p><?php _e("This is a widgeted area which is called Bottom Featured.”, 'genesis'); ?></p> </div><!-- end .wrap --> </div><!-- end .widget --> <?php endif; ?> </div><!-- end .bottom-featured--> <?php } genesis();
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.