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.
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”
Hello!
I’m so grateful to find this post! I have a specific “context” that I can’t seem to find the code for anywhere…
I have a certain category that is hidden on my blog’s main page (index.php) called “coming soon”. Right now, it can only be accessed through certain links in a tagcloud that I converted into a menu.
I would like this specific category to show up full, but have all else remain excerpts.
Do I change the following code in my archive.php only?
And if so, what do I change it to, to have category 31 (Coming-soon) show up full when the corresponding tag (such as “fish and seafood”) is clicked?
I’d appreciate any help you can give!
Kindly,
Sharon
thenourishedcook.com
Hi Sharon, there seem to be a confusion between the tags and categories concept in what you describe…
From what I understand and I can see on your website, you have created a post called “Coming soon” that you have assigned to
1) the category coming soon
2) at least on tag named fish and seafood
Your theme is apparently not Customizr or Customizr child so the above snippet will not apply.
If the theme uses the WordPress template hierarchy, you can create a specific template named category-31.php.
Hope this helps
Oh no! So sorry I never replied- I never saw your answer! Funny, it’s a year later, and I was just restarted my quest to figure this out. It took me right back where I started! 🙂 I think I might have some ideas now though. Just wanted to thank you for your time!
Can I also apply this to a “page” I created by adding a category to the menu? I want a separate page for all posts of a certain category, but I want to show the entire posts there. How can I do that?
Hi Markus, you can easily do that with the is_category() conditional tag.
Replace my-category by the slug of your category in the example below.
Hope this helps!
Cool, thanks! And how can I do that with multiple categories? I have two pages each made up of the posts of one specific category. I tried
as well as
but neither of the two works.
(Sorry, I am a complete newbie to PHP)
Hi, you have to use an array of categories : http://codex.wordpress.org/Conditional_Tag
Uhm, the link is not working. Can you point me to another place where I can find the code? I did a search on “array of categories”, but didn’t find anything that looked suitable.
Ok, I think I found it. I am using
Seems to work. Any issues to expect with that?
}