Last active
September 9, 2016 20:54
-
-
Save braddalton/5a699631b860b7d8f45901c48b9a2335 to your computer and use it in GitHub Desktop.
List All Post Titles Only in Genesis http://wpsites.net/web-design/list-all-post-titles-only-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
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