Thanks for viewing. I am using a soliloquy plugin addon to display post date in slide captions. I want to change the post date to human difference or 'hours ago' format. I'm converting get_the_date using the following in functions file

// Relative date & time
function wpse_relative_date() {
  return human_time_diff( get_the_time('U'), current_time( 'timestamp' ) ) . ' ago';
add_filter( 'get_the_date', 'wpse_relative_date' );

and the plugin is

function sol_soliloquy_fc_date_terms( $content, $post, $data ) {

    // Start Config
    $sliderSlugs = array(

    // Check slider ID is the one we want to amend
    if ( ! in_array( $data['config']['slug'], $sliderSlugs ) ) {
        return $content;

    // Build date and taxonomy terms content
    $additional_content =       

    '<div class="soliloquy-fc-date">'
        . __( '', 'soliloquy-featured-content-date-terms' ) . get_the_date( 'dS F Y', $post->ID ) . ' 

    // Return content
    return $content . $additional_content;

add_filter( 'soliloquy_fc_caption', 'sol_soliloquy_fc_date_terms', 1, 3 );

This outputs the amount of days the first post was created and all others are the same so I am guessing it's not returning each posts time because it's outside the loop. I'm a php newbie and I am guessing it's something to do with not being able to use the $post->ID inside the get_the_date.

Any help greatly appreciated!


In your filter function you should pass post ID to get_the_time() function, otherwise you will get the date from current post.

function wpse_relative_date( $date, $format, $post ) {
   return human_time_diff( get_the_time('U', $post), current_time( 'timestamp' ) ) . ' ago';
add_filter( 'get_the_date', 'wpse_relative_date', 15, 3 );


  • @Visible Add an additional argument $post to get_the_time() used in your wpse_relative_date() function. – nmr Jun 4 '19 at 18:46
  • That did it! Thank you! – Visible Jun 5 '19 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.