Add custom order to staff jobs
This commit is contained in:
@@ -49,7 +49,7 @@ class SP_Staff extends SP_Custom_Post {
|
||||
* @return array
|
||||
*/
|
||||
public function role() {
|
||||
$roles = get_the_terms( $this->ID, 'sp_role' );
|
||||
$roles = $this->get_roles();
|
||||
if ( $roles && ! is_wp_error( $roles ) ):
|
||||
return array_shift( $roles );
|
||||
else:
|
||||
@@ -64,11 +64,37 @@ class SP_Staff extends SP_Custom_Post {
|
||||
* @return array
|
||||
*/
|
||||
public function roles() {
|
||||
$roles = get_the_terms( $this->ID, 'sp_role' );
|
||||
$roles = $this->get_roles();
|
||||
if ( $roles && ! is_wp_error( $roles ) ):
|
||||
return (array) $roles;
|
||||
else:
|
||||
return array();
|
||||
endif;
|
||||
}
|
||||
|
||||
public function get_roles() {
|
||||
$roles = get_the_terms( $this->ID, 'sp_role' );
|
||||
|
||||
if ( ! is_array( $roles ) || ! sizeof( $roles ) ) return array();
|
||||
|
||||
$include = wp_list_pluck( $roles, 'term_id' );
|
||||
|
||||
return get_terms( array(
|
||||
'taxonomy' => 'sp_role',
|
||||
'hide_empty' => false,
|
||||
'orderby' => 'meta_value_num',
|
||||
'include' => $include,
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
),
|
||||
),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user