saragreenlaw
12/29/2014 - 2:19 AM

add-multiple-genesis-grid-loops

<?php
//* Do NOT include the opening php tag
 
//* Add multiple grid loops to a page template*/

remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_do_grid_loop' ); // Add custom loop

function custom_do_grid_loop() {  
		$args = array(
		'cat' => 3, // enter your category ID
		'posts_per_page'=> '4',  // overrides posts per page in theme settings
	);
	$loop = new WP_Query( $args );
	if( $loop->have_posts() ):
		echo '<div class="grid-loop">';
		while( $loop->have_posts() ): $loop->the_post(); global $post;

			$classes = 0 == $loop->current_post || 0 == $loop->current_post % 2 ? 'one-half first' : 'one-half';
			echo '<div class="' . $classes . '">'; ?>
			<a href="<?php the_permalink() ?>"><h3><?php the_title(); ?></h3></a>
			<?php the_excerpt(); ?>	
			<?php echo '</div>';
		
		endwhile;
		echo '</div>';	
	endif;



wp_reset_query();

$args = array(
		'cat' => 7, // enter your category ID
		'posts_per_page'=> '2',  // overrides posts per page in theme settings
	);
	$loop = new WP_Query( $args );
	if( $loop->have_posts() ):
		echo '<div class="grid-loop">';
		while( $loop->have_posts() ): $loop->the_post(); global $post;

			$classes = 0 == $loop->current_post || 0 == $loop->current_post % 2 ? 'one-half first' : 'one-half';
			echo '<div class="' . $classes . '">'; ?>
			<a href="<?php the_permalink() ?>"><h3><?php the_title(); ?></h3></a>
			<?php the_excerpt(); ?>	
			<?php echo '</div>';
		
		endwhile;
		echo '</div>';	
	endif;

}