Archived topic
Make post dates clickable
5 replies · Started by Jane on November 14, 2022
Hello,
I'm trying to make my post dates clickable, and found the following solution:
https://www.ramaas.com/how-to-make-your-wordpress-posts-dates-clickable/
However, I'm having a hard time identifying exactly where to put the suggested code. I don't see <?php the_time(); ?> in the index file.
Suggestions?
Thank you,
Jane
Hi Jane,
Can you link us to your site where we can see the date? The article is published 14 years ago, I don't think the info is up to date.
And where do you want the date to link to?
Sure, here is the site:
https://hotsheetpub.com/2022/05/imho-a-nuanced-look-at-hybrid-publishers/
If people click on the date, I want them to jump to a page that lists all posts published on that date.
Jane
Try this PHP snippet:
add_filter('generate_post_date_output', function($output, $time_string){
$posted_on = '<span class="posted-on">%1$s<a href="%2$s" title="%3$s" rel="bookmark">%4$s</a></span> ';
printf(
$posted_on,
apply_filters( 'generate_inside_post_meta_item_output', '', 'date' ),
esc_url( get_day_link( get_the_time( 'Y' ), get_the_time( 'm' ), get_the_time( 'd' ) ) ),
esc_attr( get_the_time() ),
$time_string
);
},10,2 );
That worked like a dream! Thank you SO much.
You are welcome :)