- This topic has 25 replies, 3 voices, and was last updated 4 years ago by David.
-
AuthorPosts
-
April 5, 2020 at 7:21 am #1227262DavidStaffCustomer Support
Hi there,
lets try this.
Find this line:
if ( get_the_modified_time( 'U' ) > get_the_time( 'U' ) ) {
and replace it with:
$pub_time = get_the_time( 'U' ); $upd_time = get_the_modified_time( 'U' ) + 86400; if ( $upd_time > $pub_time ) {
April 5, 2020 at 4:50 pm #1227896TanThank you, I tried again but it didn’t work 🙁
April 6, 2020 at 2:32 am #1228168DavidStaffCustomer SupportCan you temporarily remove that Code so we can see what the default timestamps are showing ?
April 6, 2020 at 2:49 am #1228188TanDone. I removed that code. Hope to help you.
April 6, 2020 at 9:16 am #1228763TomLead DeveloperLead DeveloperHmm, something weird going on.
Can you add this? It should output the two variables we’re comparing:
add_filter( 'generate_post_author_output', function() { return sprintf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<span class="author-name" itemprop="name">%3$s</span></span>', 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() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Đăng ngày %2$s</time>'; $updated_time = get_the_modified_time( 'U' ); $published_time = get_the_time( 'U' ); var_dump( 'Updated:' . $updated_time ); var_dump( 'Published:' . $published_time ); if ( $updated_time > $published_time ) { $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Cập nhật ngày %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() ) ); return sprintf( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'categories', ); } ); add_filter( 'generate_footer_entry_meta_items', '__return_null' );
Can you share the two values which are output so we can compare them?
April 6, 2020 at 7:12 pm #1229247April 7, 2020 at 2:50 am #1229555DavidStaffCustomer SupportAah i spotted why my effort did not apply 🙂
In Tom’s latest code, can you change:
$published_time = get_the_time( 'U' );
to:
$published_time = get_the_time( 'U' ) + 86400;
Make that edit and let us know.
April 7, 2020 at 3:09 am #1229569TanYeah It worked David. It changes published date’s custom text 😀
But can you help me to delete “string(18) “Updated:1586155300” string(20) “Published:1586241699″” after author name? It looks like this.April 7, 2020 at 3:44 am #1229606DavidStaffCustomer SupportRemove these two line:
var_dump( 'Updated:' . $updated_time ); var_dump( 'Published:' . $published_time );
April 7, 2020 at 4:09 am #1229632TanAwesome. Thank you so much for your support! 🙂
April 7, 2020 at 4:17 am #1229639DavidStaffCustomer SupportGlad we could be of help
-
AuthorPosts
- You must be logged in to reply to this topic.