- This topic has 7 replies, 3 voices, and was last updated 5 years, 5 months ago by
Tom.
-
AuthorPosts
-
December 23, 2016 at 3:28 am #257299
Chandan
Hello,
I would like to show last modified date on single post & category instead of post creation date. How can I do this?
December 23, 2016 at 3:37 am #257302Chandan
I managed to find this in forum but need some tweaking.
Currently, it shows as “Last updated: $date by author”
However, I would like to show as “By Chandan Kumar | Last Updated: $date
December 23, 2016 at 8:04 am #257342Pete
Just change your time zone
<p>By <?php the_author_meta('user_firstname'); ?> <?php the_author_meta('user_lastname'); ?> | Last updated <?php date_default_timezone_set('Australia/Perth'); echo human_time_diff(get_the_modified_date('U'), current_time('timestamp')) . ' ago'; ?></p>
December 23, 2016 at 10:51 am #257407Tom
Lead DeveloperLead DeveloperWhich function are you using? Can you link me to it?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 23, 2016 at 3:39 pm #257451Chandan
Hello Tom,
I tried this – https://gist.github.com/generatepress/57ef8336f9afec9bb42a
I see above function shows Hyperlink to date & Author. All I want to print like below.
“By $author | Last Updated: $date
Author or date shouldn’t have any hyperlink. Please let me know what all I need to.
December 23, 2016 at 10:01 pm #257491Tom
Lead DeveloperLead Developer1. Take the date and place it after the author block:
https://gist.github.com/generatepress/57ef8336f9afec9bb42a#file-template-tags-php-L21-L30
https://gist.github.com/generatepress/57ef8336f9afec9bb42a#file-template-tags-php-L432. Replace “by” with “By”: https://gist.github.com/generatepress/57ef8336f9afec9bb42a#file-template-tags-php-L36
3. Replace this line: https://gist.github.com/generatepress/57ef8336f9afec9bb42a#file-template-tags-php-L23
With:
printf( '<span class="posted-on">| Last Updated: %1$s</span>',
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 23, 2016 at 11:53 pm #257499Chandan
Date is not showing. Here is my 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 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 <span class=”author-name” itemprop=”name”>%4$s</span></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;// If our date is enabled, show it
if ( $date ) :
printf( ‘<span class=”posted-on”>| Last Updated: %1$s</span>’,
sprintf( ‘%3$s‘,
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
)
);
endif;}
endif;December 24, 2016 at 9:53 am #257569Tom
Lead DeveloperLead DeveloperAh, the code you’r using removes the date in favor of the updated date.
Remove the two forward slashes (//) on this line: https://gist.github.com/generatepress/57ef8336f9afec9bb42a#file-template-tags-php-L10
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.