Skip to content

Instantly share code, notes, and snippets.

@mattbanks
Created February 11, 2013 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbanks/4755368 to your computer and use it in GitHub Desktop.
Save mattbanks/4755368 to your computer and use it in GitHub Desktop.
Run custom loop for taxonomy archive for proper formatting, use pre_get_posts to change query to show all posts-per-page
/**
* Show header on archive pages
*/
function mb_archive_header() {
global $post;
echo '<h1 class="archive-title">Archive for &#8216;' . single_cat_title('', false) . '&#8217;</h1>';
}
/**
* Show all posts on archives instead of 8 per page
*/
function mb_archive_show_all( $query ) {
$query->set( 'posts_per_page', -1 );
return;
}
/**
* Show Portfolio list on taxonomy archive page
*/
function mb_portfolio_taxonomy_page_loop() {
global $post;
if ( have_posts() ) :
echo '<div class="workthumbs clearfix">';
while( have_posts() ): the_post();
mb_display_portfolio();
endwhile;
echo '</div><!-- .workthumbs -->';
do_action( 'genesis_after_endwhile' );
endif;
}
<?php
/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
/** Show archive header */
add_action('genesis_before_loop', 'mb_archive_header');
/** Show all posts on archives instead of 8 per page */
add_action( 'pre_get_posts', 'mb_archive_show_all' );
/** Use our own loop to display content properly */
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'mb_portfolio_taxonomy_page_loop' );
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment