guideplugin/result/template_data
Adjust the data of a list in the Result Template
guideplugin/result/template_data
Definition
With this filter you can adjust the data of a list in the Result Template.
This filter provides two hook variants: a general hook and a data source-specific hook for more targeted modifications.
Parameters
apply_filters('guideplugin/result/template_data', $data_values, $post_id, $data_source);
apply_filters('guideplugin/result/template_data/{data_source}', $data_values, $post_id, $data_source);
Parameter | Type | Description |
---|---|---|
$data_values | array | Array of the data of this element |
$post_id | int | The Post ID |
$data_source | string | The data source |
Examples
General Hook Example
The example shows you how to add the suffix 'Euro' to the ACF field 'price':
<?php
function my_guide_template_data($data_values, $post_id, $data_source) {
// Only modify data 'acf_price'
if ($data_source == 'acf_price') {
if (count($data_values) > 0) {
array_walk($data_values, function(&$value, $key) {
$value .= ' Euro';
});
}
}
return $data_values;
}
add_filter('guideplugin/result/template_data', 'my_guide_template_data', 10, 3);
Data Source-Specific Hook Example
function my_guide_template_data_price($data_values, $post_id, $data_source) {
// You don't need to check for 'acf_price'
if (count($data_values) > 0) {
array_walk($data_values, function(&$value, $key) {
$value .= ' Euro';
});
}
return $data_values;
}
add_filter('guideplugin/result/template_data/acf_price', 'my_guide_template_data_price', 10, 3);
Usage Scenarios
Data Formatting
Add currency symbols, units, or formatting to values
Data Processing
Transform raw data before display
Conditional Logic
Apply different formatting based on data source or value