Tutorial: Adding a salary field for jobs

Last updated on

Note: All code examples on this site are provided for developer reference/guidance only and we cannot guarantee that they will always work as expected. Our support policy does not include assistance with modifying or debugging code from any code examples, and they may be changed or removed if we find they no longer work due to changes in our plugins.

Update: WP Job Manager v.1.35 or above includes the Salary field as an optional field that can be enabled under Job Listings > Settings >  Job Listings.

This tutorial shows how to edit fields based on the Editing Job Submission fields doc and then output it on a single job listing. If you prefer to skip the code customization and just add a new Salary field, you can do so by downloading this free plugin from the repository instead.

Please note that this plugin currently hasn’t been updated in over a year, so your mileage may vary.

Add the field to the frontend

Open up your theme’s functions.php file, or even better, use a functionality plugin such as Code Snippets, and create a function to append a new field to the jobs section. First hook it in:

add_filter( 'submit_job_form_fields', 'frontend_add_salary_field' );

Then write the function:

function frontend_add_salary_field( $fields ) {
  $fields['job']['job_salary'] = array(
    'label'       => __( 'Salary ($)', 'job_manager' ),
    'type'        => 'text',
    'required'    => true,
    'placeholder' => 'e.g. 20000',
    'priority'    => 7
  return $fields;

This adds a salary text field at the bottom of the jobs form that has the label “Salary”, is required, has no placeholder, and is ordered in 7th position.

The salary field
The salary field

Fields added using the above code will be saved to the job listing automatically.

Add the field to admin

Again in theme functions.php, hook in your custom function:

add_filter( 'job_manager_job_listing_data_fields', 'admin_add_salary_field' );

Then write your custom function:

function admin_add_salary_field( $fields ) {
  $fields['_job_salary'] = array(
    'label'       => __( 'Salary ($)', 'job_manager' ),
    'type'        => 'text',
    'placeholder' => 'e.g. 20000',
    'description' => ''
  return $fields;

This adds a text field to the admin meta box named “salary”.

The admin salary field
The admin salary field

Note, the field name is prepended with a ‘_’. This is because Job Manager makes your new fields hidden meta by prepending theme with an underscore. This is normal.

Display “Salary” on the single job page

Our final task is to display the salary somewhere. There are two ways we can do this:

  1. We can override the template for the single job listing and output the meta data there using get_post_meta().
  2. We can use another filter and display the meta via our own function.

In this tutorial we’ll do it using option #2 and add the salary underneath the job title.

First we need to again hook our function into the correct location. This time we use an action hook:

add_action( 'single_job_listing_meta_end', 'display_job_salary_data' );

Then we write a function which gets the value of the meta and outputs it in list format:

function display_job_salary_data() {
  global $post;

  $salary = get_post_meta( $post->ID, '_job_salary', true );

  if ( $salary ) {
    echo '<li>' . __( 'Salary:' ) . ' $' . esc_html( $salary ) . '</li>';

Now when we view a job with a salary entered we will see:

2014-03-09 at 12.54

Adding Salary to Google Structured Data

To ensure Google picks up the new salary data for your listings, you’ll need to add the following code (edit currency and unitText accordingly):

// Add Google structured data

add_filter( 'wpjm_get_job_listing_structured_data', 'add_basesalary_data');

function add_basesalary_data( $data ) {
global $post;

$data['baseSalary'] = [];
$data['baseSalary']['@type'] = 'MonetaryAmount';
$data['baseSalary']['currency'] = 'USD';
$data['baseSalary']['value'] = [];
$data['baseSalary']['value']['@type'] = 'QuantitativeValue';
$data['baseSalary']['value']['value'] = get_post_meta( $post->ID, '_job_salary', true );
$data['baseSalary']['value']['unitText'] = 'YEAR';

return $data;

Adding a Salary Filter to the Job Search Form (advanced)

It is possible to add new filters to the search form by adding a field and then modifying the search queries using filters. The below example adds a dropdown ‘salary’ field, which then filters the listings based on pre-defined ranges. This only works with numeric values and requires Job Manager 1.23.6 to work correctly.