Removing Loop on Home Page

Community Forums Forums General Discussion Removing Loop on Home Page

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  brace1 1 year, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #58164

    brace1
    Participant
    Post count: 10

    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

    • This topic was modified 1 year, 1 month ago by  brace1.
    • This topic was modified 1 year, 1 month ago by  brace1.
    http://www.lasallehoops.com
    #58224

    Robin
    Participant
    Post count: 318

    Well, 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)

    #58277

    brace1
    Participant
    Post count: 10

    Yeah, I built it a different way, but I think that is where we are heading.

    Thanks.

    #58294

    brace1
    Participant
    Post count: 10

    So 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();
    
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.