WP Job Manager core plugin snippets

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.

Please use the Code Snippets plugin, rather than adding the code samples below directly to your theme’s functions.php file. That will help ensure that any code errors won’t crash your site, and the changes will not be overwritten when you update your theme.


Job Fields

Prefill the company logo field

add_filter('submit_job_form_fields', 'dm_prefill_company_logo'); // for users not logged in
add_filter('submit_job_form_fields_get_user_data', 'dm_prefill_company_logo'); // for logged in users
function dm_prefill_company_logo( $fields ) {
  $fields['company']['company_logo']['value'] = 'full_url_to_the_logo';
  return $fields;
}

Mandatory fields

Depending on which field you want to make mandatory, you can use or remove fields from the list.

add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields' , 11);

function custom_submit_job_form_fields( $fields ) {


    $fields['job']['job_location']['required'] = true;
    $fields['job']['job_tags']['required'] = true;

    return $fields;
}

Prefill application email

/**Prefill application field in frontend form**/

add_filter('submit_job_form_fields_get_user_data', 'aas_prefill_application_field');
function aas_prefill_application_field( $fields ) {
  	$fields['job']['application']['value'] = 'hello@your-link.com';
	
  return $fields;
}

Remove a field from the job submission page

add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields_dm' );

function custom_submit_job_form_fields_dm( $fields ) {
    // in this example, we remove the job_tags field
    unset($fields['job']['job_tags']);

    // And return the modified fields
    return $fields;
}

Remove all company details from the job submission page

If you want to remove the company details from the job submission form, for example, if all jobs are internal, or for the same company, you can do so by using the following snippet:

add_filter( 'submit_job_form_fields', 'gma_custom_submit_job_form_fields' );

function gma_custom_submit_job_form_fields( $fields ) {
    
    unset($fields['company']['company_name']);
    unset($fields['company']['company_website']);
    unset($fields['company']['company_tagline']);
    unset($fields['company']['company_video']);
    unset($fields['company']['company_twitter']);
    unset($fields['company']['company_logo']);

    return $fields;
}

Change the default Job Type in job submission form to ‘volunteer’

add_filter( 'submit_job_form_fields', 'submit_job_form_fields_job_type_default' , 11);
 
function submit_job_form_fields_job_type_default( $fields ) 
{
    $fields['job']['job_type']['default'] = 'volunteer'; // Slug of the job type
 
    return $fields;
}

Prefill the Locations field for a job posting to a particular town’

add_filter('submit_job_form_fields', 'bk_prefill_jobs_location');
function bk_prefill_jobs_location( $fields ) {
  $fields['job']['job_location']['value'] = 'Granite Falls, WA';
  return $fields;
}

Redirects

Use alternative login page

add_filter( 'login_url', 'my_login_page', 10, 2 );
function my_login_page( $login_url, $redirect ) {
    return home_url( '/my-custom-login-page/?redirect_to=' . $redirect );
}

Redirect to Job Dashboard after job submission

add_filter( 'job_manager_job_submitted', function() {
    if ( wp_redirect( job_manager_get_permalink( 'job_dashboard' ) ) ) {
	    exit;
	  }
}, 20 );

Make custom meta field searchable

function my_wpjm_meta_key_dm() {
    global $wpdb, $job_manager_keyword;
    $searchable_meta_keys[] = '_my_meta_field';
    return $searchable_meta_keys;
}
add_filter('job_listing_searchable_meta_keys', 'my_wpjm_meta_key_dm');

Improve WPJM search when using Polylang

add_filter( 'get_job_listings_query_args', 'pll_wpjm_change_search' );

function pll_wpjm_change_search( $args ) {
  if ( function_exists( 'pll_current_language' ) ) {
    $args['lang'] = pll_current_language();
  }
  return $args;
}

WP Admin

Remove “Listing Expires” column from Job Dashboard

/* This snippet removes the “Listing Expires” column from Job Dashboard */
add_filter( 'job_manager_job_dashboard_columns', 'remove_expires_column' ); 
function remove_expires_column( $columns ) {
    unset( $columns['expires'] );
    return $columns;
}

/* This snippet removes the “Listing Expires” column from All Jobs in wp-admin  */
add_filter( 'manage_edit-job_listing_columns', 'remove_expires_column_admin' );
function remove_expires_column_admin( $columns ) {
    unset( $columns['job_expires'] );
    return $columns;
}

Prefill application email in WP-Admin

/**Prefill email in WP-Admin form**/
add_filter('job_manager_job_listing_wp_admin_fields', 'aas_prefill_application_address_wpadmin');

function aas_prefill_application_address_wpadmin( $fields ) {
	$fields ['_application']['value'] = 'email@your-link.com';

  return $fields;
}
add_filter('job_manager_job_listing_wp_admin_fields', 'aas_job_manager_remove_featured_checkbox');
function aas_job_manager_remove_featured_checkbox( $fields ) {

	unset($fields['_featured']);
    return $fields;

}

Other

Specify language to use for geocoding

add_filter( 'job_manager_geolocation_endpoint', 'change_geocode_lang' );
function change_geocode_lang( $endpoint ) {
  // Use language from https://developers.google.com/maps/faq#using-google-maps-apis
  return add_query_arg( 'language', 'en-GB', $endpoint );
}

More about this snippet can be found here.

Add Underline button to the TinyMCE editor toolbar

add_filter( 'submit_job_form_wp_editor_args', 'customize_editor_toolbar' );

function customize_editor_toolbar( $args ) {
	$args['tinymce']['toolbar1'] = 'bold,italic,underline,|,bullist,numlist,|,link,unlink,|,undo,redo';
	return $args;
}

Add Job ID to Job Meta

<li class="job-id"><?php echo "Job ID: " . $post->ID ?></li>

Note: Put this line of code inside the file content-single-job_listing_meta.php.

Increase HTTP timeout to 30 seconds

add_filter( 'http_request_timeout', 'wpjm_extend_http_timeout', 99 );
function wpjm_extend_http_timeout( $timeout ) {
	return 30;
}

Add Display Job Categories Shortcode

function dm_display_wpjm_categories () {
 	 $terms = get_terms( array(
    'taxonomy' => 'job_listing_category',
    'hide_empty' => false,
) );
  
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
    echo '<ul>';
    foreach ( $terms as $term ) {
        echo '<li>' . '<a href="' . esc_url( get_term_link( $term ) ) . '">' . $term->name . '</a></li>';
    }
    echo '</ul>';
}
}

add_shortcode('list_categories', 'dm_display_wpjm_categories');

After adding the snippet, you can use the shortcode [list_categories] on a page to display the job categories. Please bear in mind that they will also link to the archive of job listings of the categories only if your theme has enabled full template support.

Add Display Job Categories Shortcode for a single listing

unction dm_display_wpjm_single_categories () {
    $terms = wp_get_post_terms( get_the_ID(), 'job_listing_category' );
    if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
        echo '<ul>';
        foreach ( $terms as $term ) {
            echo '<li>' . '<a href="' . esc_url( get_term_link( $term ) ) . '">' . $term->name . '</a></li>';
        }
        echo '</ul>';
    }
}
add_shortcode('list_categories_single', 'dm_display_wpjm_single_categories');
add_theme_support( 'job-manager-templates' );

Enable comments on job listings

// Add comment support to the job listing post type - you'll need to enable the comments for old listings manually
add_filter( 'register_post_type_job_listing', 'register_post_type_job_listing_enable_comments' );

function register_post_type_job_listing_enable_comments( $post_type ) {
	$post_type['supports'][] = 'comments';
	return $post_type;
}

// Make comments open by default for new job listings
add_filter( 'submit_job_form_save_job_data', 'custom_submit_job_form_save_job_data' );

function custom_submit_job_form_save_job_data( $job_data ) {
	$job_data['comment_status'] = 'open';
	return $job_data;
}

Enable archives pagination support

add_filter( 'register_post_type_job_listing', function( $array ) {
$array['rewrite']['pages'] = true;

return $array;
} );

You will need to re-save the permalinks when you add this snippet.

Change location Anywhere to Remote

add_filter('gettext', 'translate_text');

function translate_text($translated) { 
$translated = str_ireplace('Anywhere', 'Remote', $translated); 
return $translated; 
}

function jetpackme_remove_rp() {
  if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
  if ( is_singular( 'job_listing' ) ) {
    $jprp = Jetpack_RelatedPosts::init();
    $callback = array( $jprp,        'filter_add_target_to_dom' );
remove_filter( 'the_content', $callback, 40 );
  }
 }
}
add_action( 'wp', 'jetpackme_remove_rp', 20 ); 

Strip shortcodes from the job description

add_filter( 'the_content', function( $content ) {
	if ( 'job_listing' !== get_post_type() ) {
		return $content;
	}
	return strip_shortcodes( $content );
} );

Disable Promoted jobs 

Use the following filters to hide the promote job column and prompt:

add_action( 'admin_enqueue_scripts', function() {
	wp_dequeue_script( 'job_manager_job_editor_js' );
}, 90 );

add_action( 'init', function() {
	if ( class_exists( 'WP_Job_Manager_Promoted_Jobs_Admin' ) ) {
		remove_filter( 'manage_edit-job_listing_columns', [
			WP_Job_Manager_Promoted_Jobs_Admin::instance(),
			'promoted_jobs_columns',
		] );
	}
} );