ACF Card
Customize a query (WP_Query) that is used to get posts for a Card.
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 Basic 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 isn't available? Then Contact us and we'll try to add it as soon as possible.
Allows to customize WP_Query arguments that are used to get posts for an ACF Card.
add_filter('acf_views/card/query_args', function ($args, $cardId, $pageNumber) {
// any modifications to the $args here
return $args;
}, 10, 3);
$cardId
(int) ID of the current ACF Card$pageNumber
(int) Current page number. By default 1, has another number only within the AJAX pagination.
Allows to apply PHP filtering to the posts found.
add_filter(
'acf_views/card/posts_data',
function (array $postsData, int $cardId, int $pageNumber, \WP_Query $query, array $queryArgs): array {
// todo your modifications to the $postsData['postIds'] or $postsData['pagesAmount']
return $postsData;
},
10,
5
);
Allows to add custom variables to the custom markup.
add_filter('acf_views/card/custom_variables', function ($customVariables, $cardId) {
// any modifications to the $customVariables here
return $customVariables;
}, 10, 2);
$customVariables
(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}
$cardId
(int) ID of the current ACF Card
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_cards' != $tag) {
return $output;
}
// todo my custom changes for $output
return $output;
}, 10, 3);
Last modified 2mo ago