Archived topic
Time/Date on Blog Posts
11 replies · Started by Stuart on June 20, 2019
Is there a way to turn off the time and date stamp on blog posts? If so, can this be done for individual posts or is it an "all or none" thing?
Hi there,
That can done in the customizer globally:
https://docs.generatepress.com/article/blog-content-layout/
If you only want to do it on certain posts, you can use this filter:
https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98date%E2%80%99
https://docs.generatepress.com/article/option_generate_blog_settings/#examples
Let me know if this helps :)
Thank you, Leo. I will look at these things later today.
No problem :)
Happy to help with the coding part if you need.
I don't understand the code part.
$options['date'] = false;
Are you saying that I have to go into the site code and change this line of code to "true" when I want the date shown in a blog post, and then go back into the code to change it to "false" when I do not want the date shown?
You will need to use the filter. This would be an example:
add_filter( 'option_generate_blog_settings', function( $options) {
if ( is_single( '17' ) ) {
$options['date'] = false;
}
return $settings;
} );
See WordPress conditional tags here: https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
I don't really understand this but if you would be so kind as to provide the code I need to create an option for turning on or off the date stamp on the blog posts, and tell me where and how to insert it, I will try it.
Thank you.
There isn't an option for turning it on/off for individual posts.
My code above would be the closest solution.
You will need to replace 17 in the code to the actual post id you want to turn it off.
If there are multiple posts, you can use an array:
is_single( array( 17, 19, 1, 11 ) )
Leo,
Where do I find the box shown on this page with "Content" at the top of it?
It's in Customizer > Layout > Blog.
Never mind. I found it.
Glad you did!