Skip to content

Measurements

Armand Tresova edited this page Apr 30, 2024 · 2 revisions

'cooked_measurements'
Customize the measurements dropdown.

Example:

add_filter( 'cooked_measurements', 'custom_cooked_measurements', 10, 1 );

function custom_cooked_measurements( $measurements ){
    // Remove "Grams" and "Cups"
    if ( isset($measurements['g']) ): unset( $measurements['g'] ); endif;
    if ( isset($measurements['cup']) ): unset( $measurements['cup'] ); endif;

    // Add "Tons"
    $measurements['ton'] = array(
        'singular_abbr' => esc_html__( 'ton', 'cooked' ),  // Abbreviated (Singular)
        'plural_abbr' => esc_html__( 'tons', 'cooked' ),   // Abbreviated (Plural)
        'singular' => esc_html__('ton','cooked'),          // Singular
        'plural' => esc_html__('tons','cooked'),           // Plural
    );

    // Return customized array
    return $measurements;
}