Last active
January 29, 2021 15:40
-
-
Save Garconis/f04e122c5b69b65cb6a5bf5553fbcb6f to your computer and use it in GitHub Desktop.
Progress Maps | Add custom fields and taxonomy terms to map box description content
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 | |
function cspml_custom_item_description($default_content, $post_id){ | |
// get the terms of the post | |
$terms = get_the_terms( $post_id, 'product_types' ); | |
// this is a version that will output it as a basic comma-separated list | |
$terms_string = join(', ', wp_list_pluck($terms, 'name')); | |
// set the list as empty initially | |
$terms_output = ''; | |
// set the list of terms | |
foreach ($terms as $term) { | |
$terms_output .= '<li class="map-tax-'.$term->slug.'">'.$term->name.'</li>'; | |
} | |
$address_line_1 = get_post_meta($post_id, "address_line_1", true); | |
$address_line_2 = get_post_meta($post_id, "address_line_2", true); | |
$city = get_post_meta($post_id, "city", true); | |
$state = get_post_meta($post_id, "state", true); | |
$zip_code = get_post_meta($post_id, "zip_code", true); | |
$phone = get_post_meta($post_id, "phone", true); | |
$fax = get_post_meta($post_id, "fax", true); | |
$content = ' | |
<div class="map-content-wrapper"> | |
<div clas="map-taxaonomy-wrapper"><ul class="map-tax-list-wrapper">'.$terms_output.'</ul></div> | |
<div class="map-address-wrapper"> | |
<span class="map-address-line-1">'.$address_line_1.'</span> | |
<span class="map-address-line-2">'.$address_line_2.'</span> | |
<span class="map-city">'.$city.', </span><span class="map-state">'.$state.' </span><span class="map-zip-code">'.$zip_code.'</span> | |
</div> | |
<span class="map-phone"><strong>Tel: </strong>'.$phone.'</span> | |
<span class="map-fax"><strong>Fax: </strong>'.$fax.'</span> | |
</div> | |
'; | |
return $content; | |
} | |
add_filter('cspml_item_description', 'cspml_custom_item_description', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment