Created
January 25, 2013 07:27
-
-
Save media317/4632494 to your computer and use it in GitHub Desktop.
Genesis 1.9.1 Loop. Not working???!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_before_loop', 'child_maybe_do_grid_loop' ); | |
function child_maybe_do_grid_loop() { | |
// Amend this conditional to pick where this grid looping occurs | |
if ( is_page('bbtestpage') ) { | |
remove_action('genesis_before_post_content', 'genesis_post_info'); | |
// Use the prepared grid loop | |
add_action( 'genesis_loop', 'blocks_do_grid_loop' ); | |
} | |
} | |
function blocks_do_grid_loop() { | |
$args = array( | |
'cat' => '8', | |
'order' => 'DEC', | |
'posts_per_page' => '11', | |
'paged' => $paged | |
); | |
$loop = new WP_Query( $args ); | |
if( $loop->have_posts() ): | |
$count = 0; | |
echo '<div class="grid-loop">'; | |
while( $loop->have_posts() ): $loop->the_post(); global $post; | |
$count++; | |
if($count < 2): | |
echo '<div class="featured">'; | |
echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; | |
echo '<p>' . get_the_content() . '</p>'; | |
echo '</div>'; | |
echo '<div class="atr-course">'; | |
echo '<div class="atr-price">'; | |
echo '<h1>Course Cost: </h1>'; | |
echo '<h2>'; | |
genesis_custom_field('course_price'); | |
echo '</h2>'; | |
echo '</div>'; | |
echo '<div class="block-product"><h2>Additional Courses Available</h2></div>'; | |
else: | |
$classes = 0 == $loop->current_post || 0 == $loop->current_post % 2 ? 'one-half first' : 'one-half'; | |
echo '<div class="' . $classes . '">'; | |
echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; | |
echo '<p>' . get_the_excerpt() . '</p>'; | |
echo '</div>'; | |
endif; | |
endwhile; | |
echo '</div>'; | |
endif; | |
wp_reset_query(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment