If you are using the Genesis Framework and you want to display your first post in it’s full content length, but want the other posts below it to display as excerpts only so the page doesn’t get too long, you can add this code to your functions.php file:
add_action('template_redirect', 'sp_custom_post_content'); function sp_custom_post_content(){ // only work for home & blog template page if( is_home() || is_front_page() || is_page_template('page_blog.php') ){ remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_post_content', 'genesis_do_post_content' ); add_action( 'genesis_entry_content', 'genesis_do_custom_post_content' ); add_action( 'genesis_post_content', 'genesis_do_custom_post_content' ); } } function genesis_do_custom_post_content(){ global $wp_query; if( $wp_query->current_post == 0 ){ // Only first post will display full content the_content(); }else{ the_excerpt(); } }
This code will work for the home page as well as the blog template page. If you would prefer this to work on an archive page or a category page, you can change
is_page_template('page_blog.php')
to is_archive() or is_category()
If you want it to display on a particular category page, add the name of the category into the parenthesis with single quotes, like this:
is_category(‘books’)
where books would be the name of your category.
Warning: As always, any time you are making changes to PHP files, always do it through ftp or cpanel. Doing it through the WordPress editor could take down your entire site.
Thanks to pwdtechnology.com/ for this tip.
Leave a Reply