Created
February 11, 2013 16:04
-
-
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
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
/** | |
* Show header on archive pages | |
*/ | |
function mb_archive_header() { | |
global $post; | |
echo '<h1 class="archive-title">Archive for ‘' . single_cat_title('', false) . '’</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; | |
} |
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 | |
/** 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