Archived topic
Published date placement
5 replies · Started by iamarghya on March 30, 2022
https://generatepress.com/forums/topic/show-updated-published-date-with-wp-shows-posts-post-lists-and-on-normal-posts/
I read this article and implemented this but is there any chance the original published date can be placed after my featured image and before the title on this blog page. I am giving the link
Hi Iamarghya,
To confirm, are you wanting just the Last Updated date under the Featured image or the entire post meta along with the reading time?
Kindly let us know. Hope to hear from you soon. :)
No, I want the "published-on" date under the feature image, and the rest of the post meta will be in the same place for now
Try adding this PHP snippet:
add_action( 'wp', function() {
add_action( 'generate_after_entry_header', 'my_updated_date', 15 );
} );
function my_updated_date(){
$time_string = '<time class="entry-date published" datetime="%1$s"%5$s>%2$s</time>';
$updated_time = get_the_modified_time( 'U' );
$published_time = get_the_time( 'U' ) + 1800;
$schema_type = generate_get_schema_type();
$time_string = '<time class="entry-date updated-date" datetime="%3$s"%6$s>%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() ),
'microdata' === $schema_type ? ' itemprop="datePublished"' : '',
'microdata' === $schema_type ? ' itemprop="dateModified"' : ''
);
echo $time_string;
}
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Adding it through Code Snippets should work.
Then add this CSS:
.inside-article {
display:flex;
flex-direction:column;
}
.inside-article > .post-image{
order:-2;
}
.inside-article > .entry-date{
order:-1;
}
Then, you’ll need to remove the CSS you added to display the Updated date initially.
Here is an article with regards to adding CSS: https://docs.generatepress.com/article/adding-css/#additional-css
Adding it through additional CSS should work.
Kindly let us know how it goes. :)
Ya it worked Thank you
You’re welcome Iamarghya! Feel free to reach out anytime you’ll need assistance with anything else. :)