- This topic has 25 replies, 3 voices, and was last updated 6 years, 8 months ago by
Leo.
-
AuthorPosts
-
December 28, 2018 at 6:25 pm #768167
culpable
Hi,
I feel silly asking this – but which setting enables showing the “Published on” date for a wordpress page?
I remember it always being on by default, but for some reason this time it is not showing.
(I also want to show a “Last Updated: ” date – I presume this is still the best way to do it?)
Thank you in advance for your help during this holiday period
December 28, 2018 at 8:46 pm #768212Leo
StaffCustomer SupportHi there,
If you want to show both dates, remove this CSS from the documentation page:
.posted-on .updated + .entry-date { display: none; }
Let me know if this makes sense 🙂
December 28, 2018 at 9:39 pm #768229culpable
Hi Leo,
That does make sense. But I’m wondering why neither date is appearing right now, even though I haven’t added any CSS yet? Shouldn’t the “Published Date” be showing? Is this a setting somewhere that I’m missing?
December 29, 2018 at 7:14 am #768564Leo
StaffCustomer SupportIs it enabled here?
https://docs.generatepress.com/article/blog-content-layout/#singleDecember 29, 2018 at 5:34 pm #768837culpable
Yeah it is… but it’s not showing up.
There doesn’t seem to be an “entry-meta” div: https://imgur.com/a/GGcQSIO
(note that the published + updated date is showing correctly when I use WPSP plugin to display the post on another page)
December 29, 2018 at 8:16 pm #768863Leo
StaffCustomer SupportThat’s very weird.
Any custom functions added?
December 29, 2018 at 8:41 pm #768877culpable
Nothing….
It’s not a child theme. And I checked the Elements tab – no custom code running on these pages.
You can see here https://imgur.com/a/DwjnFrc that they are showing with WPSP.
I’m not sure what to do – should I maybe double check the code in the Editor?
December 29, 2018 at 9:36 pm #768897Leo
StaffCustomer SupportWPSP is separated from GP so that doesn’t tell us too much.
Can you try #1 here to eliminate any plugin conflicts first?
https://docs.generatepress.com/article/debugging-tips/December 29, 2018 at 9:50 pm #768904culpable
Ah okay, no worries. Just wanted to show that the dates actually existed.
Just to confirm before I deactivate the plugins – Will the settings all remain?
I currently have 50+ Posts under the WPSP plugin… so I’d be quite upset if that were lost :'(
December 29, 2018 at 9:52 pm #768908Leo
StaffCustomer SupportYes the settings should be fine 🙂
It was working before and now it’s not so something had to change.
December 29, 2018 at 10:01 pm #768910culpable
Deactivated it all except for GP Premium – still not showing 😐
December 30, 2018 at 9:11 am #769276Tom
Lead DeveloperLead DeveloperJust to confirm, are you wanting to display dates on pages as well as blog posts?
December 30, 2018 at 3:07 pm #769474culpable
It’s a wordpress page (which I needed to make clearer in the OP, sorry).
Your message reminded me of this code I used in my other website to display the date:
add_action( 'generate_after_entry_header', 'tu_page_meta' ); function tu_page_meta() { if ( 'page' == get_post_type() ) : ?> <div class="entry-meta"> <?php generate_posted_on(); ?> </div> <?php endif; }
Can I ask a few ignorant questions related to this:
#1 Should I add this via Generatepress -> Elements -> Hook + “Execute PHP” or via a code snippet?
#2 What is the difference between using a Hook that executes PHP vs. using a code snippet or using a child theme to insert the PHP?
#3 I was currently using this plugin (https://wordpress.org/plugins/insert-php/). I see in your “Adding PHP” post you recommend this plugin (https://en-ca.wordpress.org/plugins/code-snippets/). Is there any performance-related reasons as to why this is? (I don’t want to unnecessarily slow down my website)
#4 How can I adjust the code to also show the “Last Updated” date? Will it be there automatically, just hidden via CSS? So I’d just use this: https://docs.generatepress.com/article/show-the-updated-post-date/ to show it?Thank you very much for your help 🙂
December 30, 2018 at 3:29 pm #769481Leo
StaffCustomer SupportAhh sorry for the whole time I thought we are talking about single posts.
Yes that code is required to display date on pages.
#1 The code in that format would need to be added using Code Snippets or function.php of your child theme.
#2 Sometimes the code won’t work in hook. In this case you can also use Hook Element but the code would be like this:
<?php if ( 'page' == get_post_type() ) : ?> <div class="entry-meta"> <?php generate_posted_on(); ?> </div> <?php endif; ?>
#3 Code Snippet is the one suggested. Should have minimal impact on your site.
#4 The CSS in the doc page should still work.
December 30, 2018 at 3:57 pm #769499culpable
No worries Leo – I should have made it clearer.
In response to your comments:
#1 Okay, no problem.
#2 Strange… I still don’t understand the difference. Will need to read into it more. Is there a performance difference – i.e. should I implement it as a hook, or as a snippet?
#3 Okay. So should I convert all my PHP Snippets -> Code snippets then? Are you implying that PHP snippets is not as fast?
#4 Awesome.
Thank you for your help Leo! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.