This feature can now be enabled without writing any code, using an admin UI, with the Timeline Express – Toolbox Add-On.

Users can alter the default string ‘Announcement Date: m/d/Y’, where m/d/Y is the date that the announcement is set.

This can be easily altered using the timeline_express_announcement_date_text filter built into Timeline Express and Timeline Express Pro. If you’d like to change the text from ‘Announcement Date’ to something else or want to move where the date appears in the string you can do so using the following code snippet.

Keep in mind that this filter needs to be added to the functions.php of your active theme.

/**
 * Change 'Announcement Date: m/d/Y' to 'This Happened On m/d/Y'
 *
 * @param  string $string Original string. eg: Announcement Date %s
 *
 * @return string         The new, altered string to use
 */
function custom_announcement_date_string( $string ) {

	return _x( 'This Happened On %s', 'The announcement date.', 'timeline-express' );

}
add_filter( 'timeline_express_announcement_date_text', 'custom_announcement_date_string' );

If you wanted to change where the date appears in the string, all you need to do is move %s in the returned string. If you wanted the date to appear first, followed by a string of text – your return may look like the following:

return _x( '%s is when this happened.', 'The announcement date.', 'timeline-express' );

2 Comments

  1. Hello,

    I included the info above inside my child theme’s functions.php with the goal of changing the term ‘Announcement Date’ in each individual announcement, to read ‘This happened on ____’ instead, however, the change is not reflected.

    Have I misunderstood what this code is supposed to do?

    Or, is it possible that my changing the announcement slug from its default [/announcement/] to something else [/event/] may be affecting this step?

    Thank you.

    – Debbie

    Reply
    • Hi Debbie,

      I am going to push out an update in the next hour or so that will fix this. I have updated the above code snippet to reflect the new changes. The version is going to be version 1.3.5. Feel free to update when available, and update your function to the code in the snippet above.

      Thanks,
      Evan

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.