Site logo

[Resolved] Make post dates clickable

Home Forums Support [Resolved] Make post dates clickable

Home Forums Support Make post dates clickable

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2415643
    Jane

    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

    #2415726
    Ying
    Staff
    Customer Support

    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?

    #2420370
    Jane

    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

    #2420470
    Ying
    Staff
    Customer Support

    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 );
    #2420475
    Jane

    That worked like a dream! Thank you SO much.

    #2420499
    Ying
    Staff
    Customer Support

    You are welcome 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.