Sports Professionals
//Get the unique Disciplines recorded in the category
function get_meta_values( $key = 'Discipline', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_col( $wpdb->prepare( "
SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
AND p.post_status = '%s'
AND p.post_type = '%s'
ORDER BY pm.meta_value ASC
", $key, $status, $type ) );
return $r;
}
$meta_values = get_meta_values( 'Discipline' );
if( !empty( $meta_values ) ) {
$meta_counts = array();
foreach( $meta_values as $meta )
$meta_counts[] = $meta;
}
//Get the unique Leagues recorded in the category
function get_meta_values_l( $key = 'League', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_col( $wpdb->prepare( "
SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
AND p.post_status = '%s'
AND p.post_type = '%s'
ORDER BY pm.meta_value ASC
", $key, $status, $type ) );
return $r;
}
$meta_value_league = get_meta_values_l( 'League' );
if( !empty( $meta_value_league ) ) {
$meta_counts_league = array();
foreach( $meta_value_league as $meta_league )
$meta_counts_league[] = $meta_league;
}
//$args = array( 'category' => 8 );
//$posts = get_posts($args);
//$meta_values = array();
//foreach ($posts as $post) {
// $meta = get_post_meta($post->ID, 'Discipline', true);
// if the value is repeated, we don't need to save it.
// if (!(in_array( $meta, $meta_values))) {
// $meta_values[]=$meta;
// }
//}
?>
Sporting Discipline Selected: -