Filter the salary output
/**
* Filters the salary output to replace 'PerAnnum' with 'per annum'.
*
* @param string $salary The salary.
* @param array $attrs The attributes of this job data.
*
* @return string The salary output.
*/
function recpress_custom_salary_output( $salary, $attrs ) {
// get the salary from value.
$salary_to = get_post_meta( $attrs['post_id'], '_job_salary_to', true );
// get the salary per value.
$salary_per = get_post_meta( $attrs['post_id'], '_job_salary_unit', true );
// if we don't salary to, just return the salary.
if ( empty( $salary_to ) ) {
return $salary;
}
// Change salary per value.
$salary_per = str_replace( 'PerAnnum', 'per Annum', $salary_per );
// return salary output.
$salary = number_format( (float) $salary_to, 0 ) . ' ' . $salary_per;
// add dollar sign to salary output.
$salary = '$' . $salary;
// return the salary
return $salary;
}
add_filter( 'recpress_job_data_value_job_salary', 'recpress_custom_salary_output', 10, 2 );