Archived topic
Latest Post in the header element
29 replies · Started by Deep on April 22, 2019
Did these issues only start happening once we added the second function?
Well not exactly. I found the reason that it's because of the Cache dynamic CSS settings. Once I unchecked it the duplication error gone. But I realized two things out of this.
1) We have to write manual excerpts within the post to reflect in the header element, else it remains blank (auto excerpts are highly appreciated like post archives).
2) It was overlooked. The code to get_the_date is returning the publishing date of the page where the element is located. I need the date of the post displaying in the header element i.e. the latest post.
For better understanding, you can have a look at the screenshot http://prntscr.com/nh3ipp
I just adjusted the code so the date should work: https://generatepress.com/forums/topic/latest-post-in-the-header-element/#post-876757
get_the_excerpt() shouldn't require manual excerpts - it should grab them from your content. I wonder if there's a plugin conflicting? Can you try deactivating your other plugins to test?
Well, the date problem is solved. But interestingly I find the fault with the code regarding the excerpt. It is the same way the date was displaying, the excerpts are showing/not showing (depends) in the header element.
See on the front page I am using WP Show Post shortcode, hence it could not find any excerpt to show. Here is the screenshot http://prntscr.com/nhcufm
But in the case of the single post page, the header element shortcode is picking up the excerpt where the header element is located and not of the post displaying in the header.
It will clear from this screenshot http://prntscr.com/nhcxeg
I think the excerpt in the shortcode needs to be defined as you have done in the case of date
Hmm, the excerpt is already using that same method. Is this the same for all single posts?
Yes its happening on all the single post page. Have a look at my website https://bihog.com
Hi,
After updating the new code it is showing some fatal error. See the screenshot
http://prntscr.com/nhmywz
Sorry about that, can you try again?
Almost done except this first 'Read more' button which is targeting the same page where the header element is located and not the post title and excerpt displaying in the header element. Have a look into the screenshot.
http://prntscr.com/nhsyvf
But the second 'Read more' button is ok- targeting the single post page displaying in the header element.
Look at this link below to understand the things https://bihog.com/tcil-recruitment-2019-last-date-14-may-2019/
P.S.: Can we limit the length of the characters in the excerpt?
Well, the excerpt is only showing the number 30. Have a look at the screenshot.
http://prntscr.com/nhygwz
Sorry about that, can you try now?
Many many thanks.
The problem has been sorted out. I really appreciate your patience and skill.
Thank you very much. Have a look at the screenshot http://prntscr.com/ni6vyi
Glad I could help! :)