Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Last active July 12, 2024 09:56
Show Gist options
  • Save propertyhive/80698d32208bf487deeb9a50a902e5b2 to your computer and use it in GitHub Desktop.
Save propertyhive/80698d32208bf487deeb9a50a902e5b2 to your computer and use it in GitHub Desktop.
Move Council Tax Band from features to description in Reapit/Jet imports
add_action( "propertyhive_property_imported_jet", 'move_ctb_to_descriptions', 10, 2 );
function move_ctb_to_descriptions($post_id, $property)
{
$council_tax_description = '';
// Remove from features
$features = array();
if ( isset($property->AccommodationSummary) && is_array($property->AccommodationSummary) && !empty($property->AccommodationSummary) )
{
$features = $property->AccommodationSummary;
}
$i = 0;
foreach ( $features as $feature )
{
if ( strpos(strtolower($feature), 'council tax band') === FALSE )
{
update_post_meta( $post_id, '_feature_' . $i, $feature );
++$i;
}
else
{
$council_tax_description = $feature;
$council_tax_description = str_replace("Council Tax Band", "", $council_tax_description);
$council_tax_description = trim($council_tax_description, ':');
$council_tax_description = trim($council_tax_description);
update_post_meta( $post_id, '_council_tax_band_custom', $council_tax_description);
}
}
update_post_meta( $post_id, '_features', $i );
}
add_filter( 'propertyhive_single_property_meta', 'add_council_tax_band_to_meta' );
function add_council_tax_band_to_meta( $meta )
{
global $property;
$council_tax_band = $property->council_tax_band_custom;
if ( $council_tax_band != '' )
{
$meta['council-tax-band'] = array(
'label' => __('Council Tax Band', 'propertyhive'),
'value' => $council_tax_band
);
}
return $meta;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment