- This topic has 7 replies, 2 voices, and was last updated 3 years, 1 month ago by
Tom.
-
AuthorPosts
-
November 29, 2019 at 6:34 am #1082939
Chris
Hi,
Is it possible to remove Modified Date from the HTML, rather than just hiding it with CSS?
November 29, 2019 at 7:41 pm #1085171Tom
Lead DeveloperLead DeveloperYou don’t want the modified date at all? If not, try this PHP:
add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); return sprintf( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 2, 2019 at 10:15 am #1090175Chris
Hi Tom,
Thanks for this but it doesn’t seem to have worked. I can still see the date in the html, with display: none; set. I have edited my initial post to show the URL
Out of interest, why do you hide it with CSS rather than remove it with PHP when a user has opted not to include it in the GP settings? π
December 2, 2019 at 6:02 pm #1090778Tom
Lead DeveloperLead DeveloperAre you already using a function to alter the post meta/date? Your HTML on the site doesn’t reflect the function I mentioned above.
The GP setting to remove the date should fully remove the date from the HTML.
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 3, 2019 at 3:27 am #1091312Chris
Ah yes you were correct, I had some more code in there so I have now combined the two.
Also, apologies as I was mistaken about the setting to remove the date.
I had misremembered and thought there were separate options to show Date Published and Date Modified, but there is only a single option to control the date being shown.
My concern with hiding things via CSS is that it can look deceptive from an SEO point of view. I don’t think that is an issue here, but I prefer to just remove it if it is not being used.
December 3, 2019 at 9:21 am #1091995Tom
Lead DeveloperLead DeveloperIn most cases, Google knows whether you’re being deceptive or not.
Did you get the above function working now?
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 4, 2019 at 3:05 am #1092870Chris
Yes I did, thank you.
December 4, 2019 at 10:31 am #1093494Tom
Lead DeveloperLead DeveloperAwesome, no problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.