• Hi

    I’m using the following to show ‘3 days ago’ for example for each post. Is there a way to change the word ‘days’ to just say ‘d’?

    <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' '; ?>

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • This would require editing core wordpress files as far as I know.

    Go to wp-includes/formatting.php

    Around line 2101 (just search for function human_time_diff) you will see

    $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
     } elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) {
    $hours = round( $diff / HOUR_IN_SECONDS );
    if ( $hours <= 1 ) {
    $hours = 1;
    }
    $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
     } elseif ( $diff >= DAY_IN_SECONDS ) {
    $days = round( $diff / DAY_IN_SECONDS );
    if ( $days <= 1 ) {
    $days = 1;
    }
    $since = sprintf( _n( '%s day', '%s days', $days ), $days );

    so change %s days to %s d or whatever you want!

    Just remember to backup that file incase of mistakes, and any WordPress Core updates will overwrite any changes you make!

    Never, ever edit core files. Neither encourage others to do so. It can create more problems than solving, including bringing down your whole site and opening your site an easy target to hackers.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Showing 'd' instead of 'days'’ is closed to new replies.