By default, Matador Jobs displays job listings in newest-first order. However, there are many reasons you may want to customize this default sort order, for example, if you use a custom field like priority to manually rank jobs for visibility.
This article explains how to change the default ordering of job listings using WordPress filters and Matador’s extensibility.
Use Case Example: Ordering by a priority Custom Field
Suppose you’ve added a custom field named priority to your job posts, with values like 1, 2, or 3. You want job listings to appear in ascending order, with priority 1 jobs shown first.
To achieve this, you’ll need to:
- Import your custom field so it’s available to WordPress.
- Hook into
pre_get_poststo modify the query for the jobs archive.
Step 1: Import the Custom Field
Matador does not import custom fields by default. To use fields like priority for ordering, you’ll need to ensure they are available as post meta.
We recommend using our Job Object Customizer add-on. With this, you can map your ATS fields to WordPress meta fields (like priority) during import.
Step 2: Hook into the pre_get_posts Filter
Once the priority field is imported, you can customize the job archive query using WordPress’s pre_get_posts filter.
Here’s an example snippet:
function matador_docs_order_jobs_by_priority( $query ) {
// Only modify the main query on the job listings archive
if ( $query->is_post_type_archive( 'matador-job-listings' ) && $query->is_main_query() ) {
// Tell WordPress which custom field to use
$query->set( 'meta_key', 'priority' );
// Order by the numerical value of the field
$query->set( 'orderby', 'meta_value_num' );
// Ascending order: 1 (high priority) appears before 3 (low priority)
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'matador_docs_order_jobs_by_priority' );
This function checks that we’re modifying the main query on the job listings archive, and then sets WordPress to order by the priority field numerically, in ascending order.
Notes on Ordering Options
You can order job listings by:
- Numeric fields (e.g. priority, salary): use
meta_value_num - Alphabetic fields (e.g. speciality, contract type): use
meta_value - Dates (e.g. custom deadlines): use
meta_valueormeta_value_num, depending on the format
To learn more about how order and orderby work in WordPress, see the official documentation: WP_Query Reference: order & orderby parameters
Wrapping Up
Custom ordering can help you surface high-priority or relevant jobs more effectively. With the Job Object Customizer and a small code snippet, you can tailor the job listing order to meet your specific needs.
Need help with your use case? Contact our support team