Advanced Views Docs
Live PlaygroundDownload PluginGet PRO
  • πŸ’‘Help Centre
  • ⚑Getting Started
    • Introduction
      • Key Aspects
      • Creating Your First View
      • Creating Your First Card
      • Plugin Terms
      • Plugin Interface
        • Field Options
    • Installation
      • Advanced Views Lite
      • Advanced Views Pro
      • Comparison Table
      • Upgrading from Lite to Pro
    • Supported data vendors
    • Starter theme
  • 🌟Display Content
    • WordPress
      • Post
      • Taxonomy terms
      • User
      • Comments
      • Menus
    • WooCommerce Product
    • Meta fields
      • Basic fields
        • Number
      • Content fields
        • Image
        • File
        • WYSIWYG
        • oEmbed
        • Gallery
      • Choice fields
        • Select/checkbox/radio
        • True / False
      • Relationship fields
        • Link
        • Post_object
        • Page Link
        • Relationship
        • Taxonomy
        • User
      • Advanced fields
        • Google Map
        • Google Map Multiple Markers
        • ACF OpenStreetMap Field
        • Date/time picker
      • Layout fields
        • Group (Pro)
        • Repeater (Pro)
        • Flexible (Pro)
    • Object fields
    • Custom Data (Pro)
    • Custom Gutenberg Blocks (Pro)
    • Mount Points (Pro)
    • Front-end assets management (Pro)
  • πŸ¦Έβ€β™‚οΈQuery Content
    • Basic Filters
    • Meta Filters (Pro)
      • Current Post
      • Comparison
      • Dynamic Injection
    • Taxonomy Filters (Pro)
    • Pagination (Pro)
    • Custom Data (Pro)
  • πŸ†Shortcode Attributes
    • Common Arguments
    • View Shortcode
    • Card Shortcode
  • πŸ§™β€β™‚οΈTemplates
    • Customizing the Template
    • Template engines
      • Twig
      • Blade
    • CSS & JS
      • BEM Methodology
      • WordPress Interactivity API
    • File system storage
    • Pre-built components
    • Reusable components library (Pro)
    • Live reload
    • Multilingual
    • Custom Ajax & Rest API (Pro)
  • β˜•Guides
    • Display Custom Post Type (CPT) on another post
    • Display Employees (CPT) of a Company (CPT)
    • Display Nested Repeater Fields
    • Map Marker from ACF Image
    • Display all CPT items on a single map
  • πŸ› οΈTools
    • Export/Import
    • Demo Import
    • Settings
    • Preview
  • 🏹Troubleshooting
    • Compatibility
    • Report a bug
    • Payment Issues
    • Lite Support (Forum)
    • Pro Support
  • βš™οΈCustomization
    • Filters and Hooks
      • View
      • Card
    • Suggest a feature
    • Performance
Powered by GitBook
On this page
  • Common hooks list
  • Common hooks description
  • Container (Pro)
  • Custom Twig functions (Pro)
  • Custom Twig filters (Pro)

Was this helpful?

  1. Customization

Filters and Hooks

Customize the query and output of the shortcode for a View.

PreviousPro SupportNextView

Last updated 11 months ago

Was this helpful?

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 plugin versions, where some are only available in the Pro version, these have been labelled as (Pro).

This page lists hooks that are common for both Views and Cards. Check the child pages to see hooks related to Views and Cards.

Common hooks list

(Pro)

(Pro)

(Pro)

Common hooks description

Container (Pro)

Using this hook, you can define a , and then use it inside and classes.

use DI\Container;

$container = new Container();

add_filter( 'acf_views/container', function () use ( $container ) {
	return $container;
} );

Custom Twig functions (Pro)

add_filter('acf_views/twig/custom_functions', function (array $customFunctions): array {
    return array_merge($customFunctions, [
        [
            'prefixer',
            function ($firstArg) {
                return 'prefix2' . $firstArg;
            }
        ]
    ]);
});

add_filter('acf_views/twig/custom_functions', function (array $customFunctions): array {
    return array_merge($customFunctions, [
        [
            'prefixerWithHtml',
            function ($firstArg) {
                return '<strong>prefix</strong>' . $firstArg;
            },
            ['is_safe' => ['html',],]
        ]
    ]);
});

For the function callback, you can define as much arguments as you need.

Now you can call your functions in twig templates of your Views and Cards.

{{ prefixer(myVar) }}
{{ prefixerWithHtml(myVar) }}

Custom Twig filters (Pro)

add_filter('acf_views/twig/custom_filters', function (array $customFunctions): array {
    return array_merge($customFunctions, [
        [
            'prefixer',
            function ($value, $firstArg) {
                return $firstArg . $value;
            }
        ]
    ]);
});

add_filter('acf_views/twig/custom_filters', function (array $customFunctions): array {
    return array_merge($customFunctions, [
        [
            'prefixerWithHtml',
            function ($value, $firstArg) {
                return '<strong>'.$firstArg.'</strong>' . $value;
            },
            ['is_safe' => ['html',],]
        ]
    ]);
});

For the filter callback, you can define as many arguments as you need.

Now you can call your filters in twig templates of your Views and Cards.

{{ myVar|prefixer("prefix") }}
{{ myVar|prefixer("prefix") }}

Do you need to customize something but a filter isn't available?

Note: every item of the array represents the custom function. First argument is the function name, second is the callback. Third argument is optional, here you can pass any supported by Twig.

Note: every item of the array represents the custom filter. First argument is the filter name, second is the callback. Third argument is optional, here you can pass any supported by Twig.

Then and we'll try to add it as soon as possible.

βš™οΈ
function settings
filter settings
Contact us
PHP-DI container
Custom_View_Data
Custom_Card_Data
Read more
acf_views/container
acf_views/twig/custom_functions
acf_views/twig/custom_filters