Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active September 9, 2016 20:54
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 braddalton/5a699631b860b7d8f45901c48b9a2335 to your computer and use it in GitHub Desktop.
Save braddalton/5a699631b860b7d8f45901c48b9a2335 to your computer and use it in GitHub Desktop.
add_action( 'pre_get_posts', 'mjg_show_titles_only_category_pages' );
function mjg_show_titles_only_category_pages( $query ) {
if( $query->is_main_query() && $query->is_category() || $query->is_search() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
$query->set( 'posts_per_page', '-1' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'mjg_custom_loop' );
}
}
function mjg_custom_loop() {
echo '<ul class="category-post-title-list">';
while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
<?php
endwhile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment