Grid Loop Has Me Stumped

Community Forums Forums General Discussion Grid Loop Has Me Stumped

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  jbculp 1 year ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #63658

    jonahgirl
    Participant
    Post count: 5

    I upgraded a site that used the Education theme from Genesis 1.9.2 to 2.0.1 (also updated WP to latest version 3.6.1)
    I have the grid loop at the bottom. Before the update the bottom showed two posts each with a “Read More” button. The read more was manually inserted by by client at this choice of location rather than a set limit in the Genesis Theme settings.
    I had already applied the grid loop fix by wpsmith/bill erikson when I upgraded to 1.9
    I have this on my home.php`add_action( 'genesis_loop', 'education_grid_loop_helper' );
    function minimum_grid_loop_helper() {

    if ( function_exists( 'genesis_grid_loop' ) ) {
    genesis_grid_loop( array(
    'features' => 2,
    'feature_image_size' => 'featured',
    'feature_image_class' => 'post-image',
    'feature_content_limit' => 0,
    'grid_image_size' => 'thumbnail',
    'grid_image_class' => 'alignleft',
    'grid_content_limit' => 200,
    'more' => __( '[Read more]', 'education' ),
    ) );
    } else {
    genesis_standard_loop();
    }

    }`

    I have this in my functions.php file`/**fixing the grid loop**/

    /**
    * Possibly amend the loop.
    *
    * Specify the conditions under which the grid loop should be used.
    *
    * @author Bill Erickson
    * @author Gary Jones
    * @author Travis Smith
    * @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/
    * @link http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/
    *
    * @return boolean Return true of doing the grid loop, false if not.
    */
    function wps_is_doing_grid_loop() {
    // Amend this conditional to pick where this grid looping occurs.
    // This says to use the grid loop everywhere except single posts,
    // single pages and single attachments.
    return ( ! is_singular() );
    }
    add_action( 'pre_get_posts', 'wps_include_cat_in_grid' );
    /**
    * Limit Query to one Category
    *
    * @author Bill Erickson
    * @author Travis Smith
    * @link http://www.billerickson.net/customize-the-wordpress-query/
    * @link http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/
    * @param object $query WP Query data
    *
    */
    function wps_include_cat_in_grid( $query ) {
    if( $query->is_main_query() && $query->is_home() && wps_is_doing_grid_loop() ) {
    $query->set( 'cat', '4' );
    $query->set( 'posts_per_page', '2' );
    }
    }

    `
    If I try and set the content limit on the grid loop it doesn’t change.
    If I switch to twenty twelve the more links kick in on the main page. The more links work on all the blog pages.
    I am just stumped. I have turned off all the plugins as well.
    The site is http://bcinstitue.com

    Note: I have a back up which I loaded and upgraded all plugins and wordpress but did not upgrade Genesis. All was fine.

    • This topic was modified 1 year, 1 month ago by  jonahgirl.
    • This topic was modified 1 year, 1 month ago by  jonahgirl.
    http://bcinstitue.com
    #63664

    jonahgirl
    Participant
    Post count: 5

    The back up was set up as test in another folder. The live site is still “broken”

    #67066

    jbculp
    Participant
    Post count: 119

    I’m having the same issue with education theme. No matter what I do I get more posts than desired on the home page (grid was set to 1 featured and 4 in grid and I have 1 featured and 11 or more).

    Bill Erickson’s blog post seems to be closed to comments so I can’t ask there. Do you have a solution yet? If I figure it out I’ll share if I find it.

    #67068

    jonahgirl
    Participant
    Post count: 5

    Number of posts was not my issue. The Read More link stopped working…yes I did get a fix.
    Nick gave me the answer to add this to my home.php file

    global $more;
      $more = 0;

    So it looks like this

    <?php
    
    add_action( 'genesis_meta', 'education_home_genesis_meta' );
    /**
     * Add widget support for homepage. If no widgets active, display the default loop.
     *
     */
    function education_home_genesis_meta() {
    	
    	global $paged;
    	
    	if( $paged < 1 ) {
    		if ( is_active_sidebar( 'slider' ) || is_active_sidebar( 'intro' ) || is_active_sidebar( 'featured' ) || is_active_sidebar( 'call-to-action' ) ) {
    		
    			add_action( 'genesis_before_content', 'education_home_loop_helper', 1 );
    	
    		}
    	}
    	
    }
    
    function education_home_loop_helper() {
    		
    		echo '<div id="home-featured">';
    		
    		genesis_widget_area( 'slider', array( 
    		
    			'before'	=>	'<div class="slider widget-area">' 
    		
    		) );
    
    		genesis_widget_area( 'intro', array( 
    		
    			'before'	=> 	'<div class="intro widget-area"><div class="inner">', 
    			'after'	=>	'<div class="clear"></div></div></div><!-- end .intro -->' 
    		
    		) );
    		
    		genesis_widget_area( 'featured', array(
    		 
    			'before'	=>	'<div class="featured widget-area"><div class="inner">', 
    			'after'	=>	'<div class="clear"></div></div></div><!-- end .featured -->' 
    			
    		) );
    		
    		genesis_widget_area( 'call-to-action', array(
    		
    			'before'	=>	'<div class="call-to-action"><div class="banner-left"></div>', 
    			'after'	=>	'<div class="banner-right"></div></div><!-- end .call-to-action -->'
    		
    		) );	
    		
    	
    
    		echo '</div>';
    
    		global $more;
    		$more = 0;
    		
    }
    add_action( 'pre_get_posts', 'be_include_category_from_blog' );
    /**
     * Include Category from Blog
     * 
     * @author Bill Erickson
     * @link http://www.billerickson.net/customize-the-wordpress-query/
     * @param object $query data
     *
     */
    function be_include_category_from_blog( $query ) {
    	
    	if( $query->is_main_query() && $query->is_home() ) {
    		$query->set( 'cat', '4' );
    	}
     
    }
    
    genesis();

    The grid loop fix is needed in the functions.php file would control the number of posts on the home page
    By setting the total number of posts per page that should fix the grid number run amok..set this to 5

    /**
    * Possibly amend the loop.
    *
    * Specify the conditions under which the grid loop should be used.
    *
    * @author Bill Erickson
    * @author Gary Jones
    * @author Travis Smith
    * @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/
    * @link http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/
    *
    * @return boolean Return true of doing the grid loop, false if not.
    */
    function wps_is_doing_grid_loop() {
    // Amend this conditional to pick where this grid looping occurs.
    // This says to use the grid loop everywhere except single posts,
    // single pages and single attachments.
    return ( ! is_singular() );
    }
    add_action( 'pre_get_posts', 'wps_include_cat_in_grid' );
    /**
    * Limit Query to one Category
    *
    * @author Bill Erickson
    * @author Travis Smith
    * @link http://www.billerickson.net/customize-the-wordpress-query/
    * @link http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/
    * @param object $query WP Query data
    *
    */
    function wps_include_cat_in_grid( $query ) {
    if( $query->is_main_query() && $query->is_home() && wps_is_doing_grid_loop() ) {
    $query->set( 'cat', '4' );
    $query->set( 'posts_per_page', '2' );
    }
    }

    Hope you get it worked out.
    mel

    #67069

    jbculp
    Participant
    Post count: 119

    Excellent. Thanks I’ll give it all a try.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.