Created
November 20, 2015 23:15
-
-
Save jamiemitchell/24b9fe3830d091291615 to your computer and use it in GitHub Desktop.
Show CPT and Tax archive pages as a list in Genesis
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 | |
//* 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