FacetWP – stick custom data into FWP_JSON

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

add_filter( ‘facetwp_assets’, function( $assets ) {

// Populate “FWP_JSON.neighborhood_data”
FWP()->display->json[‘neighborhood_data’] = array(
‘academy’ => array(
‘title’ => ‘Academy’,
‘description’ => ‘This is the description’,
‘image’ => ‘http://image.url’,
),
‘airport’ => array(
‘title’ => ‘Airport’,
‘description’ => ‘This is the description’,
‘image’ => ‘http://image.url’,
)
);

// Return the same thing (since we’re hijacking this hook)
return $assets;
});
{{/gist}}