- This topic has 20 replies, 4 voices, and was last updated 1 week ago by
Fernando.
-
AuthorPosts
-
January 21, 2023 at 5:13 am #2503832
Vijaykumar
Hi
The CSS method to show last updated date here https://docs.generatepress.com/article/show-the-updated-post-date/ is working to show last updated date for wordpress POSTS only but I am finding it hard to show the last updated date for the wordpress PAGES.Is there any different code for PAGES to show last updated date? Any tweak required for this css code? Or any other method?
I tried the filter mentioned here as well https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date but it’s also not working for showing PAGE updated date.January 21, 2023 at 5:20 am #2503835David
StaffCustomer SupportHi there,
by default Pages do not display the entry meta, so you need to enable that to see the date.
This doc explains:https://docs.generatepress.com/article/add-entry-meta-to-pages/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 21, 2023 at 6:10 am #2503863Vijaykumar
Thanks so much, this worked!
January 21, 2023 at 7:54 am #2504063David
StaffCustomer SupportGlad to hear that
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 22, 2023 at 5:00 pm #2505224Scott
I use a different method using a custom shortcode you might find useful so i’ll share
function post_modified_date() { return get_the_modified_date(); } add_shortcode( 'modified_date', 'post_modified_date' );
usage:
Last Updated: [modified_date] to the page you desire. (I use it in a shortcode block in The gutenberg.
January 23, 2023 at 3:48 am #2505630David
StaffCustomer SupportThanks Scott!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 25, 2023 at 1:07 am #2508191Vijaykumar
Hi David
I see the last updated date is shown on frontend with this change but the published date is still in the backend when we inspect the page. We want to REMOVE the published date for both posts and pages including comments. Any idea how we can remove it entirely from the page? We don’t want to show “datePublished” even in the code backend may it be added by theme or any plugin. Can this be done?January 25, 2023 at 1:21 am #2508214Fernando Customer Support
Hi Vijaykumar,
Can you try re-adding this code?:
add_filter( 'generate_post_date_show_updated_only', '__return_true' );
We’ll check your post and page again afterward.
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
January 25, 2023 at 1:33 am #2508224Vijaykumar
This filter is added. Can you please check.
Posts/pages still showing entries such as:class=”entry-date published” datetime=’…
<meta property=”article:published_time” content=”..
“datePublished”:”..January 25, 2023 at 1:39 am #2508225Fernando Customer Support
To clarify, may we know how you specifically added the snippet?
Moreover, do you have any other code for the date aside from the one here?: https://docs.generatepress.com/article/add-entry-meta-to-pages/
January 25, 2023 at 1:53 am #2508245Vijaykumar
Using Code snippet plugin. https://ibb.co/rMc6QyF
January 25, 2023 at 1:59 am #2508248Vijaykumar
FYI,
We had the code below but when we updated to PHP 8 it started giving error like undefined ‘$time_string’ error on server.if ( ! function_exists( 'generate_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function generate_posted_on() { $date = apply_filters( 'generate_post_date', true ); $author = apply_filters( 'generate_post_author', true ); //if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) $time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>'; $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); // If our date is enabled, show it if ( $date ) : printf( '<span style="float: left; margin-right: 3px;">Last Updated:</span><span class="posted-on">%1$s</span>', sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>', esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ) ); endif; // If our author is enabled, show it if ( $author ) : printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>', __( 'by','generatepress'), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); endif; } endif;
January 25, 2023 at 2:55 am #2508302David
StaffCustomer SupportIn regards to your reply here:
https://generatepress.com/forums/topic/unable-to-show-last-updated-date-on-pages/#post-2508191When you say in the Backend – do you mean in the post/page editor ?
Or do you mean in the websites HTML ?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 25, 2023 at 3:59 am #2508381Vijaykumar
Hi David
I mean page Html when we inspect live pages and posts. I have given example urls in my first message to test links.We do not want to show the published date in any format on the page. I have given examples of 3 instances where it is currently being shown.
January 25, 2023 at 4:13 am #2508396David
StaffCustomer SupportThis is what i see in the Page URL you shared above:
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.