# Post Selection

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 isn't available? Then [Contact us](https://advanced-views.com/support/) and we'll try to add it as soon as possible.

## List

[acf\_views/card/query\_args](#query-args) (Pro)

[acf\_views/card/query\_args/id={cardId}](#query-args) (Pro)

[acf\_views/card/posts\_data](#posts-data) (Pro)

[acf\_views/card/posts\_data/card\_id={cardId}](#posts-data) (Pro)

[acf\_views/card/custom\_variables](#custom-post-selection-variables)

[acf\_views/card/custom\_variables/card\_id={cardId}](#custom-post-selection-variables)

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

## Description

### Query Args

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

{% code overflow="wrap" %}

```php
add_filter('acf_views/card/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(
   'acf_views/card/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('acf_views/card/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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wplake.gitbook.io/advanced-views/customization/filters-and-hooks/post-selection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
