Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hi John,

    You can tap into the simple_links_link_output filter to append the date.
    If you add the following to your active theme’s functions.php file, it should do what you want:

    add_filter( 'simple_links_link_output', 'sl_add_date' );
    function sl_add_date( $output ){
    	return str_replace( '</a>', ' ' . get_the_date() . '</a>', $output );
    }

    Hope this helps!

    Thread Starter joleksow

    (@joleksow)

    Hi Mat,

    Thanks for this tip! However, it seems like the date that’s being retrieved from get_the_date is the date of the page the links are appearing on and not the links themselves.

    I got this working by modifying the code you provided to look more like this:

    add_filter( 'simple_links_link_output', 'sl_add_date' 10, 3);
    function sl_add_date( $output, $meta, $link ){
            $sl_date = mysql2date ('F j, Y', $link->post_date);
    	return str_replace( '</a>', ' ' . $sl_date . '</a>', $output );
    }

    This is working great, but if you have other ideas for how to do this more elegantly I would be all ears.

    Thanks!
    John

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display published date using shortcode?’ is closed to new replies.