-
-
Save anythinggraphic/3ab48c8b17d90c8c1ff5 to your computer and use it in GitHub Desktop.
Custom Category Loop - Missing Pagination
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
<?php | |
/** | |
* Template Name: Category Template: Art Three | |
* Description: Page template for the Art Category | |
*/ | |
// Remove Genesis loop | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
// Add our custom loop | |
add_action( 'genesis_loop', 'pg_art_loop' ); | |
function pg_art_loop() { | |
global $post; | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
global $only_query; | |
$only_query = new WP_Query( 'paged=' . $paged . '&offset=1'); | |
// Pagination fix | |
$temp_query = $wp_query; | |
$wp_query = NULL; | |
$wp_query = $only_query; | |
if( $only_query->have_posts() ) : | |
$i = 1; | |
$ids = array(); | |
// loop through posts | |
while( $only_query->have_posts() ): $only_query->the_post(); | |
$ids[] = get_the_ID(); | |
if($i < 4) { | |
$widthclass = "one-fourth"; | |
} else { | |
$widthclass = ""; | |
} | |
if($i == 1 || $i == 4) { | |
$widthclass .= " first"; | |
} else { | |
$widthclass .= ""; | |
} | |
if($i == 4) { | |
$widthclass .= " one-half"; | |
} else { | |
$widthclass .= ""; | |
} | |
// First Widget (one-fourth) | |
if ( is_active_sidebar('category_middle') && $i==4 ) { | |
genesis_widget_area('category_middle'); | |
echo '<div class="clearfix"></div>'; | |
} | |
echo '<div class="'. trim($widthclass) . '">'; | |
// This is for putting the right featured image in the right post. Plugin: Multiple Post Thumbnails | |
if($i == 5){ | |
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-featured-image', NULL, 'featured-image-400-square'); | |
} else { | |
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-featured-image', NULL, 'featured-image-400-square'); | |
} | |
echo '<h4>' . get_the_title() . '</h4>'; | |
echo '<p>' . get_the_date() . '</p>'; | |
echo '</div>'; | |
// Second Widget (one-half) | |
// change the id? | |
if(is_active_sidebar('category_middle') && $i==4 ) { | |
genesis_widget_area('category_middle'); | |
echo '<div class="clearfix"></div>'; | |
} | |
$i++; | |
endwhile; | |
do_action( 'genesis_after_endwhile' ); | |
//genesis_posts_nav(); | |
endif; | |
wp_reset_query(); | |
// Reset main query object | |
$wp_query = NULL; | |
$wp_query = $temp_query; | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment