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 Lite and Pro Editions, where some are only available in the Pro Edition, these have been labelled as (Pro).
Do you need to customize something but a filter or hook is unavailable?
Then Contact us and we'll try to add it as soon as possible.
Allows you to amend 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 herereturn $fieldData;},10,3);
$field_data (array) Field data
$field_meta (Field_Meta_Interface) Information about the field.
$view_id (string) Unique ID of the current View.
Custom View Variables (Pro)
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 herereturn $phpVariables;},10,4);
$php_variables (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}
$view_id (string) Unique ID of the current View.
$object_id (int) ID of the current data post
$field_values (array) An associative field values array, where keys are field identifiers
Shortcode output
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 $outputreturn $output;},10,3);
FieldMeta
Some filters have a plugin's class instances as arguments. These classes implement interfaces, and if you want to declare a type of a filter argument in your code, you must use an interface instead of a class name.