How to show a single post on Blog and only titles on Category archives in Genesis

Posted on

In the comments section my How to show only Post titles on category pages in Genesis article, a user asked:

This is almost exactly what I need. However, my client’s blog posts are REAAAALLLLYYYY long bible studies. So on the main blog page (which is not the home page – it’s another menu item), I just want to show one blog post. But for the category listings, I want to show all titles on one page for that category. Is there a way to do this?

I have recorded a screencast in which you can see how the above can be done.

Note: In the video you can see that I have added the actions code inside functions.php. Since we want this only for category archives, the code should instead be placed in category.php (anywhere between the opening PHP tag and closing genesis() function call).

Showing just one entry on the Posts page

add_action( 'pre_get_posts', 'sk_change_blog_posts_per_page' );
/**
 * Change Posts Per Page for Posts page
 *
 * @author Bill Erickson
 * @link http://www.billerickson.net/customize-the-wordpress-query/
 * @param object $query data
 *
 */
function sk_change_blog_posts_per_page( $query ) {

	if( $query->is_main_query() && !is_admin() && is_home() ) {
		$query->set( 'posts_per_page', '1' );
	}

}

Displaying only titles for Posts on Category Archives

category.php:

remove_action( 'genesis_entry_header', 'genesis_do_post_format_image', 4 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );

remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 );
remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );

remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );

remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );

add_action( 'loop_start', 'sk_opening_articles_tag' );
function sk_opening_articles_tag() {
echo '<div class="articles">';
}

add_action( 'loop_end', 'sk_closing_articles_tag' );
function sk_closing_articles_tag() {
echo '</div>';
}

genesis();

style.css:

.category .content .entry {
	margin-bottom: 0;
	padding-bottom: 0;
	padding-top: 20px;
}

.category .content .entry-title {
	font-size: 24px;
}

.category .articles {
	padding-top: 20px;
	padding-bottom: 40px;
	background-color: #fff;
}