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 Lite 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 or hook is unavailable?

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

List

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 (Pro)

acf_views/view/custom_variables/view_id={viewId} (Pro)

do_shortcode_tag

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

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

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

Last updated