Display the full post content in specific contexts

Updated March 2015 This snippet applies to Customizr > 3.3.1 and Customizr-Pro > 1.0.12. If you’re running an older version replace ‘tc_show_excerpt’ with ‘tc_show_post_list_excerpt’

The Customizr theme allows you to set the length of the posts content (full content or excerpt) in list of posts (blog page, home, archives, …) in Appearance > Customize > Pages & Posts Layout.

This global option will then apply to all the lists of posts of your website.

If you need to apply a specific length to your posts for a given context, then you will need to use a hook called : ‘tc_show_post_list_excerpt’. This is actually a boolean filter : if set to true, your posts will show their excerpts, if set to false, your posts will be displayed in full content.

Note: This snippet doesn’t apply in context where you use the Grid layout.

 

Let’s assume that you have set the global option to excerpt and you need to display your blog posts in full length only on home page. The following snippet will do it :

add_filter('tc_show_excerpt' , 'show_post_in_full_length');
function show_post_in_full_length($bool) {
	if ( !is_home() )
		return $bool;//<= if current context is not home
					//then use the global option set in Appearance > Customize > Pages & Posts layout
	return false;//<= else set to false to display the full post content
}

As always, don’t forget to do all your customizations in a child theme as explained here.

9 thoughts on “Display the full post content in specific contexts”

Comments are closed.