Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Show CPT and Tax archive pages as a list in Genesis
//* 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>
echo '</ul>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment