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
  • List
  • Description
  • Field Data
  • Custom View Variables (Pro)
  • Shortcode output
  • FieldMeta

Was this helpful?

  1. Customization
  2. Filters and Hooks

View

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

PreviousFilters and HooksNextCard

Last updated 1 month 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 versions, 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 and we'll try to add it as soon as possible.

List

(Pro)

(Pro)

Description

Field Data

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 here
    return $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 here
    return $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

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);

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.

namespace Org\Wplake\Advanced_Views\Views;

interface Field_Meta_Interface {
	// getters.
	public function is_field_exist(): bool;

	public function get_field_id(): string;

	public function get_name(): string;

	public function get_type(): string;

	public function get_return_format(): string;

	public function get_display_format(): string;

	/**
	 * @return array<string, string>
	 */
	public function get_choices(): array;

	public function is_multiple(): bool;

	public function is_repeater(): bool;

	public function get_self_repeatable_meta(): ?Field_Meta_Interface;

	/**
	 * @return string|string[]
	 */
	public function get_default_value();

	public function get_zoom(): int;

	public function get_center_lat(): string;

	public function get_center_lng(): string;

	public function get_vendor_name(): string;

	/**
	 * @return mixed
	 */
	public function get_custom_arg( string $arg_name );

	// setters.

	public function set_is_field_exist( bool $is_field_exist ): void;

	public function set_name( string $name ): void;

	public function set_type( string $type ): void;

	public function set_return_format( string $return_format ): void;

	public function set_display_format( string $display_format ): void;

	/**
	 * @param array<string|int,mixed> $choices
	 */
	public function set_choices( array $choices ): void;

	public function set_is_multiple( bool $is_multiple ): void;

	public function set_is_repeater( bool $is_repeater ): void;

	public function set_self_repeatable_meta( ?Field_Meta_Interface $self_repeatable_meta ): void;

	/**
	 * @param string|string[] $default_value
	 */
	public function set_default_value( $default_value ): void;

	public function set_zoom( int $zoom ): void;

	public function set_center_lat( string $center_lat ): void;

	public function set_center_lng( string $center_lng ): void;

	/**
	 * @param mixed $arg_value
	 */
	public function set_custom_arg( string $arg_name, $arg_value ): void;

	public function unset_custom_arg( string $arg_name ): void;
}

It’s a built-in WordPress hook that allows modifying the output of the whole shortcode. Code example shown below. Read more .

βš™οΈ
here
Contact us
acf_views/view/field_data
acf_views/view/field_data/type={fieldType}
acf_views/view/field_data/name={fieldName}
acf_views/view/field_data/view_id={viewId}
acf_views/view/custom_variables
acf_views/view/custom_variables/view_id={viewId}
do_shortcode_tag