Site logo

[Resolved] Displaying Posted (and updated) Date on pages

Home Forums Support [Resolved] Displaying Posted (and updated) Date on pages

Home Forums Support Displaying Posted (and updated) Date on pages

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • #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

    #768212
    Leo
    Staff
    Customer Support

    Hi 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 🙂

    #768229
    culpable

    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?

    #768564
    Leo
    Staff
    Customer Support
    #768837
    culpable

    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)

    #768863
    Leo
    Staff
    Customer Support

    That’s very weird.

    Any custom functions added?

    #768877
    culpable

    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?

    #768897
    Leo
    Staff
    Customer Support

    WPSP 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/

    #768904
    culpable

    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 :'(

    #768908
    Leo
    Staff
    Customer Support

    Yes the settings should be fine 🙂

    It was working before and now it’s not so something had to change.

    #768910
    culpable

    Deactivated it all except for GP Premium – still not showing 😐

    #769276
    Tom
    Lead Developer
    Lead Developer

    Just to confirm, are you wanting to display dates on pages as well as blog posts?

    #769474
    culpable

    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 🙂

    #769481
    Leo
    Staff
    Customer Support

    Ahh 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.

    #769499
    culpable

    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! 🙂

Viewing 15 posts - 1 through 15 (of 26 total)
  • You must be logged in to reply to this topic.