• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

all pages not work when change default genesis_loop

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › all pages not work when change default genesis_loop

This topic is: not resolved

Tagged: genesis_loop

  • This topic has 3 replies, 3 voices, and was last updated 8 years, 6 months ago by coralseait.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • February 21, 2015 at 1:11 pm #141670
    kmallahi
    Member

    Hi all

    I am now change the default genesis_loop with this code :-

    
    /*
    
    * Chang loop to grid flex
    
    */
    
    remove_action('genesis_loop','genesis_do_loop');
    
    add_action('genesis_loop','an_loop_helper');
    
    function an_loop_helper() {
    
    global $post;	
    
    $i=0;
    
    $args = array(
    
    		'post_type'      => 'post',
    
    		'posts_per_page' => 10,
    
    		'post_status'    => 'publish',
    
    		'paged'          => get_query_var( 'paged' )
    
    );
    
    global $wp_query;
    
    $wp_query = new WP_Query( $args );
    
    if ( have_posts() ) : 
    
    while ( have_posts() ) : the_post(); 
    
    ?>
    
    <article class="latestPost excerpt <? if($i%2==0){?> first <? } ?>" itemscope="" itemtype="http://schema.org/BlogPosting">
    
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" id="featured-thumbnail">
    
    <div class="featured-thumbnail">
    
    <?php					
    
    if ( has_post_thumbnail() ) {
    
    the_post_thumbnail(array('370','297'));
    
    }
    
    ?>
    
    </div>
    
    <?
    
    $category = get_the_category(get_the_id()); 
    
    $cat_id = $category[0]->term_id;
    
    $cat_data = get_option("category_$cat_id");
    
    if (isset($cat_data['cat_color'])){
    
    ?>
    
    <div class="post-label" style="background:<? echo $cat_data['cat_color'];?> !important">
    
    <span><?php echo get_the_category_list( ', ' ); ?></span>
    
    </div>
    
    <?
    
    }
    
    else
    
    {
    
    ?>
    
    <div class="post-label"><span><?php echo get_the_category_list( ', ' ); ?></span></div>
    
    <?
    
    }
    
    ?>
    
    </a>
    
    <header>
    
    <h2 class="title front-view-title" itemprop="headline">
    
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    
    <?php the_title(); ?>
    
    </a>
    
    </h2>
    
    </header>
    
    </article>
    
    <? 
    
    endwhile;
    
    do_action( 'genesis_after_endwhile' );
    
    endif;
    
    wp_reset_query();
    }
    

    In home page its work good, But when open any page or post.

    I don't see the content, its still show me my custom loop.

    Why ?

    http://test.abunawaf.com
    February 21, 2015 at 1:12 pm #141671
    kmallahi
    Member

    Its my test web page so the images not show

    March 9, 2015 at 2:55 pm #143830
    Raviraya
    Member

    Hi,

    I have same problem in my web site, Please help me in this.

    March 9, 2015 at 8:27 pm #143872
    coralseait
    Member

    Yes, that's the expected behaviour; you've changed the default loop everywhere by your action statements. If you only want it on certain pages or types of pages you'll need to use conditionals such as is_home etc.

    You should also issue a wp_reset_query after your wp_query

    EDIT - Never mind on wp_reset_query, just noticed on your last line.


    Coral Sea IT

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble