[Resolved] Show last modified date on pages only

Home Forums Support [Resolved] Show last modified date on pages only

Home Forums Support Show last modified date on pages only

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #622578
    Mike

    Want to show the last modified date on pages, and created date on posts.

    Followed this – https://generatepress.com/forums/topic/show-last-modified-date-to-pagesposts/ – and pages are great, but it applies to posts as well. I want posts back to normal with created date.

    Thanks!

    #622695
    David
    Staff
    Customer Support

    Hi there,

    you can use this method instead:

    PHP Snippet:

    add_action( 'generate_after_entry_header', 'tu_page_meta' );
    function tu_page_meta() {
        if ( is_singular( 'page' ) ) : ?>
            <div class="entry-meta">
                <?php generate_posted_on(); ?>
            </div><!-- .entry-meta -->
        <?php endif;
    }

    CSS:

    .page .posted-on .updated {
    	display: inline-block;
    }
    .page .posted-on .published {
    	display: none;
    }
    #623304
    Mike

    That works! Except, I also want to remove the “by” and author. I think that was in the generate_posted_on in the way I had before.

    #623331
    Tom
    Lead Developer
    Lead Developer

    Along with the code David supplied, try this:

    add_action( 'wp', 'tu_remove_page_byline' );
    function tu_remove_page_byline() {
        if ( is_page() ) {
            add_filter( 'generate_post_author', '__return_false' );
        }
    }

    Let me know ๐Ÿ™‚

    #623778
    Mike

    That worked. Thanks!

    Dunno if being able to toggle all of this through the regular backend page editor could be a future feature, as it seems like it could be a common use.

    Scenario: A static front page, the basic content unit on the site is a page (not a post), and the blog is a blog. On some pages, like the home page, a datestamp isn’t required, but an pages that are articles, a datestamp is, sometimes without the author (like maybe, a glossary or an About page), sometimes with (a regular article).

    On my site, I don’t need author on any page, for now at least, so the solution you gave works, along with a snippet in Simple CSS to hide the date on some pages. Fairly efficient.

    .entry-meta {
        display: none;
    }

    Thanks again!

    #623855
    Tom
    Lead Developer
    Lead Developer

    No problem! Really appreciate your feedback ๐Ÿ™‚

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