-
-
Save pije76/cfb4730931c78fd76d4b87bca0a3e984 to your computer and use it in GitHub Desktop.
WP Job Manager Job List Custom Sort by Meta Field Value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters | |
function xyz_custom_orderby( $query_args ) { | |
// Use meta_value_num for numeric sorting (if issues with meta_value) | |
$query_args[ 'orderby' ] = 'meta_value'; | |
$query_args[ 'order' ] = 'ASC'; | |
return $query_args; | |
} | |
add_filter( 'job_manager_get_listings_args', 'xyz_custom_orderby', 99 ); | |
function xyz_custom_orderby_query_args( $query_args ) { | |
$query_args[ 'cache-bust' ] = time(); | |
$query_args[ 'meta_key' ] = '_job_salary' | |
return $query_args; | |
} | |
add_filter( 'get_job_listings_query_args', 'xyz_custom_orderby_query_args', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment