Archived topic
Show last modified date on pages only
5 replies · Started by Mike on July 12, 2018
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!
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;
}
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.
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 :)
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!
No problem! Really appreciate your feedback :)