Comment on page
ACF View
Customize the query and output of the shortcode for a View.
Please make sure you've installed the latest version of the plugin before using these filters.
Some filters are common and available in both the Basic and Pro plugin versions, where some are only available in the Pro version, these have been labelled as "(Pro)".
Do you need to customize something but a filter isn't available? Then Contact us and we'll try to add it as soon as possible.
Allows to amend a field data before it's inserted into the template.
add_filter('acf_views/view/field_data', function ($fieldData, $fieldMeta, $viewId) {
// any modifications to the $fieldData here
return $fieldData;
}, 10, 3);
$fieldData
(array) Field data$viewId
(string) Unique ID of the current ACF View.
Allows to customize the default field markup.
add_filter('acf_views/view/field_markup', function ($fieldMarkup, $fieldMeta, $viewId) {
// any modifications to the $fieldHTML here
return $fieldMarkup;
}, 10, 3);
$fieldMarkup
(string) Markup of the field.$viewId
(string) Unique ID of the current ACF View.
Allows to add custom variables to the custom markup.
add_filter('acf_views/view/custom_variables', function ($phpVariables, $viewId, $objectId, $fieldValues) {
// any modifications to the $phpVariables here
return $phpVariables;
}, 10, 4);
$phpVariables
(array) Current custom variables (Custom Markup Variables field, an associative array of values, where keys are variable names). These variables can be accessed in the custom markup with brackets, like{VARIABLE_NAME}
$viewId
(string) Unique ID of the current ACF View.$objectId
(int) ID of the current data post$fieldValues
(array) An associative field values array, where keys are field identifiers
It’s a built-in WordPress hook that allows modifying the output of the whole shortcode. Code example shown below. Read more here.
add_filter('do_shortcode_tag', function ($output, $tag, $attr) {
if ('acf_views' != $tag) {
return $output;
}
// todo my custom changes for $output
return $output;
}, 10, 3);
Last modified 2mo ago