Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to hide the word “ago” from freshness…


  • joymoleta
    Participant

    @joymoleta

    I’ve searched and searched and I just can’t figure it out. Can someone please help? Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

  • Robin W
    Moderator

    @robin-w

    try adding this to your functions file

    function change_translate_text( $translated_text ) {
    if ( $translated_text == ‘%s ago’) {
    $translated_text = ‘%s’;
    }
    return $translated_text;
    }
    add_filter( ‘gettext’, ‘change_translate_text’, 20 );

    Functions files and child themes – explained !


    joymoleta
    Participant

    @joymoleta

    Thank you so much! This worked perfectly.

    Would you now how to abbreviate the verbiage? I’d prefer x hrs, x mins if possible. Just thought I’d ask. Thank you again.


    lflier
    Participant

    @lflier

    Here is a straightforward approach to abbreviating the time. Just put it in your functions.php file. You can modify the abbreviations as you wish:

    add_filter( 'bbp_get_time_since', 'abbreviate_time' );
    function abbreviate_time ( $output ) {
        $output = str_replace( 'minutes', 'min', $output );
        $output = str_replace( 'minute', 'min', $output );
        $output = str_replace( 'hours', 'hr', $output );
        $output = str_replace( 'hour', 'hr', $output );
        $output = str_replace( 'weeks', 'wk', $output );
        $output = str_replace( 'week', 'wk', $output );	
        $output = str_replace( 'months', 'mo', $output );
        $output = str_replace( 'month', 'mo', $output );    
        $output = str_replace( 'years', 'yr', $output );
        $output = str_replace( 'year', 'yr', $output );    
        return $output;
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar