-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
54 lines (39 loc) · 1.32 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
//Modify marker based on taxonomy
add_filter(
'wp_grid_builder_map/geojson',
function( $json, $facet ) {
$json['features'] = array_map(
function( $feature ) {
$icon_url = '';
$post_id = $feature['properties']['id'];
$terms = get_the_terms( $post_id, 'act_cat' );
// get the current taxonomy term
$term = get_queried_object();
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
// vars
$image = get_field('t_marker', $term);
// image id is stored as term meta
// $image_id = get_term_meta( $term->term_id, 'image', true );
// $image_id = get_term_meta( $term->term_id, 'image', true );
// image data stored in array, second argument is which image size to retrieve
$image_data = wp_get_attachment_image_src( $image_id, 'full' );
// icon url is the first item in the array (aka 0)
$icon_url = $image;
}
if ( ! empty( $icon_url ) ) {
$feature['properties']['icon']['url'] = $icon_url;
}
else {
}
return $feature;
},
$json['features']
);
return $json;
},
10,
2
);