- This topic has 5 replies, 2 voices, and was last updated 6 years, 8 months ago by Tom.
-
AuthorPosts
-
August 21, 2017 at 2:36 pm #370751Philip
Good day, as per title say looking for a code to add in child theme functions php file already searched most topics but can’t make it to work on my site to display like this under title in one line.
Published on (Date) at (Time) | Updated on (Date) at (Time) by (Author)
I know many people asking about this but it does not work with my site those codes and i try already many hours but the codes are complicated.August 22, 2017 at 12:03 am #370946TomLead DeveloperLead DeveloperHi there,
Have you tried this?: https://generatepress.com/forums/topic/how-to-show-last-updated-date-in-posts/#post-355267
Let me know ๐
August 22, 2017 at 4:28 am #371114PhilipYes the dates only are shown without time and without words just linked together looks ugly even if i change to block still not as desired.
I want to customize them with words and time for each published and updated like this.
Published on (Date) at (Time) | Updated on (Date) at (Time) by (Author)
Tried different combinations but could not make it work as i need that is why i decided to ask how to edit this code.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 ); $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; 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 ) { echo apply_filters( 'generate_post_date_output', sprintf( '<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 ) ), $time_string ); }
I know this is out of support so i would like to donate as you helped me with other codes before.
Thank you for your time.August 22, 2017 at 11:46 pm #371688TomLead DeveloperLead DeveloperThis should do it: https://gist.github.com/generatepress/8bc94ae43f67c40a077aefc8ec970fd0
August 23, 2017 at 3:48 am #371841PhilipIt works, you are the best.
I have send you a small donation.
Thank you!August 23, 2017 at 10:07 am #372062TomLead DeveloperLead DeveloperThank you! I really appreciate it! ๐
-
AuthorPosts
- You must be logged in to reply to this topic.