Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Created November 20, 2015 23:15
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 jamiemitchell/24b9fe3830d091291615 to your computer and use it in GitHub Desktop.
Save jamiemitchell/24b9fe3830d091291615 to your computer and use it in GitHub Desktop.
Show CPT and Tax archive pages as a list in Genesis
<?php
//* Show code archive pages as list
add_action( 'pre_get_posts', 'code_show_titles_only_archive_pages' );
function code_show_titles_only_archive_pages( $query ) {
if( $query->is_main_query() && !$query->is_feed() && !is_admin() && $query->is_post_type_archive( 'code' ) || is_tax('code-tag') ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'code_archive_custom_loop' );
}
}
function code_archive_custom_loop() {
echo '<ul class="code-list">';
while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
<?php
endwhile;
echo '</ul>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment