Site logo

Archived topic

Post date & updated date

3 replies · Started by Laurent on July 26, 2018

Viewing posts 1–4 of 4

Hi,

In some cases, customers wish to see either :
- post date -> included natively
- updated date -> not included natively, some articles written about it
- post date & update date at same time --> my wish & it appears no where

May I ask you why customers with premium plugin doesn't have it natevily?

Hi there,

You should be able to do something as simple as this:

.posted-on .updated {
    display: inline-block;
}

.posted-on .updated:before {
    content: "Last Updated: "
}

.posted-on .published:before {
    content: " | Published on: "
}

Let me know :)

It's a partial solution.

I wish Published then Updated. It show the opposite.
Also Author is display whereas I unchecked it in Premium settings.

You can change the order with this function:

add_filter( 'generate_post_date_output', function( $output ) {
	$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_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() )
	);

	echo sprintf( '<span class="posted-on">%1$s</span>', // WPCS: XSS ok, sanitization ok.
		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
			esc_url( get_permalink() ),
			esc_attr( get_the_time() ),
			$time_string
		)
	);
} );

As for the author - do you have any other custom functions added to your site?

This archived topic is closed to new replies.