> For the complete documentation index, see [llms.txt](https://wplake.gitbook.io/advanced-views/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wplake.gitbook.io/advanced-views/post-selections/component-options/wordpress-hooks.md).

# Selection WordPress hooks

Advanced Views includes a set of WordPress filters, allowing you to customize [*Post Selections*](/advanced-views/getting-started/first-post-selection.md) from your theme (or code snippets). Pay attention that in ordinary cases, customization should be done using the [Selection Controller](/advanced-views/post-selections/code-fields/selection-controller.md).

{% hint style="info" %}
This page focuses only on the *Post Selection* hooks; check [this page](/advanced-views/features/wordpress-hooks.md) to see generic plugin hooks.
{% endhint %}

## 1. Selection hooks list

{% hint style="info" %}
Please make sure you've installed the latest version of the plugin before using these filters.

If you need to customize something, but a filter or hook is unavailable, then [contact us](https://advanced-views.com/support/), and we will try to add it as soon as possible.
{% endhint %}

[advanced\_views/post\_selection/query\_args](#query-args) (Pro)

[advanced\_views/post\_selection/query\_args/id={id}](#query-args) (Pro)

[advanced\_views/post\_selection/posts\_data](#posts-data) (Pro)

[advanced\_views/post\_selection/posts\_data/selection\_id={id}](#posts-data) (Pro)

[advanced\_views/post\_selection/custom\_variables](#custom-post-selection-variables)

[advanced\_views/post\_selection/custom\_variables/selection\_id={id}](#custom-post-selection-variables)

[do\_shortcode\_tag](#shortcode-output)

## 2. Selection hook descriptions

#### Query Args

Allows to customize WP\_Query arguments that are used to get posts for a *Post Selection*.

{% code overflow="wrap" %}

```php
add_filter('advanced_views/post_selection/query_args', function ($args, $cardId, $pageNumber) {
    // any modifications to the $args here
    return $args;
}, 10, 3);
```

{% endcode %}

* `$args` (array) Arguments for WP\_Query. See all available [here](https://developer.wordpress.org/reference/classes/wp_query/).
* `$card_id` (string) Unique ID of the current *Post Selection*
* `$page_number` (int) Current page number. By default 1, has another number only within the AJAX pagination.

#### Posts Data

Allows to apply PHP filtering to the posts found.

{% code overflow="wrap" %}

```php
add_filter(
   'advanced_views/post_selection/posts_data',
   function (array $posts_data, string $card_dd, int $page_number, \WP_Query $query, array $query_args): array {
       // todo your modifications to the $postsData['postIds'] or $postsData['pagesAmount']
       return $postsData;
   },
   10,
   5
);
```

{% endcode %}

#### Custom *Post Selection* Variables

Allows to add custom variables to the custom markup.&#x20;

{% code overflow="wrap" %}

```php
add_filter('advanced_views/post_selection/custom_variables', function ($customVariables, $cardId) {
    // any modifications to the $customVariables here
    return $customVariables;
}, 10, 2);
```

{% endcode %}

* `$custom_variables` (array) An associative array of values, where keys are variable names. These variables can be accessed in the custom markup with brackets, like `{VARIABLE_NAME}`
* `$card_id` (string) Unique ID of the current *Post Selection*

#### 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](https://developer.wordpress.org/reference/hooks/do_shortcode_tag/).

{% code overflow="wrap" %}

```php
add_filter('do_shortcode_tag', function ($output, $tag, $attr) {
    if ('acf_cards' != $tag) {
        return $output;
    }

    // todo my custom changes for $output

    return $output;
}, 10, 3);
```

{% endcode %}
