Skip to content

Instantly share code, notes, and snippets.

@Fitoussi
Last active January 4, 2016 23:21
Show Gist options
  • Select an option

  • Save Fitoussi/ae68054bd805eba5356a to your computer and use it in GitHub Desktop.

Select an option

Save Fitoussi/ae68054bd805eba5356a to your computer and use it in GitHub Desktop.
WP Job Manager geolocation - Pre category map icon
function gjm_per_category_map_icon( $map_icon, $post ) {
// get Job Type terms attached to a job
$job_terms = wp_get_post_terms( $post->ID, 'job_listing_type', array( 'fields' => 'ids' ) );
// if term ID is 1
if ( in_array( '1', $job_terms) ) {
$map_icon = 'https://maps.google.com/mapfiles/ms/icons/yellow-dot.png';
// if term ID is 2
} elseif ( in_array( '2', $job_terms) ) {
$map_icon = 'https://maps.google.com/mapfiles/ms/icons/orange-dot.png';
// if term ID is 3
} elseif ( in_array( '3', $job_terms) ) {
$map_icon = 'https://maps.google.com/mapfiles/ms/icons/green-dot.png';
}
return $map_icon;
}
add_filter( 'gjm_map_icon', 'gjm_per_category_map_icon', 10, 2 );
add_filter( 'gjm_global_map_icon', 'gjm_per_category_map_icon', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment