- This topic has 14 replies, 5 voices, and was last updated 4 years, 4 months ago by
Elvin.
-
AuthorPosts
-
November 21, 2021 at 2:50 am #2012916
crosby87
Hi there,
I have previously added the options to show ‘Last updated’ date for my blog posts in case there was an update since the original posting.
However, for some of my blog posts this does not appear. I think it has to do with the change in the heading that I have made.I have the following code in the heading of the article where it is not appearing (among others):
<h1> {{post_title}} </h1> <div class="hero-meta"> {{post_author}} | {{post_date}} {{custom_field.name}} </div>Could you please help? See links in private below.
November 21, 2021 at 5:53 am #2013046David
StaffCustomer SupportHi there,
do you want the Header Element to only display one date ? ie. the published or last updated if it exists… if so try the snippet here:
November 21, 2021 at 9:23 am #2013459crosby87
Hi there,
Thanks.
When I added the code below it added the date to a strange place. Please see the screenshot, circled: https://imgur.com/qieqL06
I have added the following code, as shown on David’s comment above:
function post_modified_date() { return get_the_modified_date(); } add_shortcode( 'modified_date', 'post_modified_date' );I have now removed the code, because I cannot leave it like that for long.
1. Could you please help fix that?
2. Where exactly do I need to add this? [modified_date]November 21, 2021 at 12:01 pm #2013613Ying
StaffCustomer SupportHi there,
You can use
Last updated: [modified_date]to replace{{post_date}}in your header element.November 22, 2021 at 1:00 am #2014105crosby87
Hi Ying,
Thanks. I have added, but like I said before, there’s an additional date popping up in my content:https://imgur.com/qieqL06
Please see it circled. I have added my date to the header (see link in private), but the circled one appears IN ADDITION.
How can I remove that?
November 22, 2021 at 10:42 am #2015486crosby87
Hi there,
Seems this was missed. Thanks
November 22, 2021 at 11:01 am #2015583Ying
StaffCustomer SupportThat is the default post meta, you should be able to disable it in customizer > layout > blog > content > single, uncheck the
display post dateoption.
https://docs.generatepress.com/article/blog-content-layout/#singleNovember 22, 2021 at 11:06 am #2015612crosby87
Ying,
If I do that then the date will no longer appear on my other blog posts.
Like I said, I have two types of blog posts.
1) the normal looking ones where I still want the date to appear (see example links in private)
2) the ones where the header is modified and to which I now added the code referred to earlier by DavidNovember 22, 2021 at 11:43 am #2015770Ying
StaffCustomer SupportThe 2 links you provided both have a header element:
https://www.screencast.com/t/pE1ey1wFdaLPIn order to provide solution, I need to know what’s the differences between these 2 type of posts? Are they in different category?
Or one of them should have NO header element applied?
November 22, 2021 at 11:45 am #2015775crosby87
Sorry, now fixed. No longer has.
November 22, 2021 at 12:12 pm #2015866Ying
StaffCustomer SupportI’m still seeing the header element, maybe a cache issue.
Can you give this CSS a try:
.single-post .page-hero ~ .site .entry-header > .entry-meta { display: none; }Let me know 🙂
November 22, 2021 at 12:21 pm #2015907crosby87
works perfectly, many many thanks!
November 22, 2021 at 12:32 pm #2015948Ying
StaffCustomer SupportYou are welcome 🙂
November 24, 2021 at 6:15 pm #2020649Lucie
Very useful thread, thank you. Follow up question, is it possible to use {{modified_date}} as a template tag (in the context of adding a New Element of type Header? I ask, because I can use {{post_date}} template tag, just wondering if I can just use {{modified_date}} instead of some of the other less elegant options listed above. Thanks in advance.
November 24, 2021 at 6:29 pm #2020652Elvin
StaffCustomer SupportHi Lucie,
Shortcode usage was suggested because there’s no template tag exactly for modified date.
{{post_date}} actually adds in an element for modified date but hides it by default. In a sense, you can use it to serve as the modified date template tag as well.
You can make it appear with this CSS:
.page-hero time.updated { display: block; }Or if you want to use {{post_date}} for both modified date and post date then you have to wrap the template tag with a selector so you can specify which one will display the modified tag.
Example HTML:
<span class="modified-date-tag"> {{post_date}} </span> <span class="post-date-tag"> {{post_date}} </span>With this HTML structure, we can turn the {{post_date}} tag under modified-date-tag to display the modify date using this CSS:
.page-hero span.modified-date-tag time.updated { display: block; } -
AuthorPosts
- You must be logged in to reply to this topic.