Open xu4wang opened 1 week ago
Doesn't look like it, there is no filter in place. I suppose there could be one here:
So replace it with:
return apply_filters('afb_get_attributes', $attributes, $args, $tags);
(I'll include it in the next release so it won't disappear with a plugin update) and then you can use something like:
add_filter('afb_get_attributes', function($attributes) {
foreach($attributes as $key => $value) {
$attributes[$key] = str_replace('{{my_dynamic_permalink}}', esc_js(get_the_permalink()), $value);
}
return $attributes;
});
Alternatively you could locate the dynamic value with AlpineJS on the page, if it's available:
<!-- wp:query -->
<div class="wp-block-query">
<!-- wp:post-template -->
<!-- wp:post-title {"isLink":true,"attributesForBlocks":{"x-cloak":""}} /-->
<!-- wp:post-date {"attributesForBlocks":{"x-data":"{href: $el.previousElementSibling.querySelector('a').getAttribute('href')}","x-text":"href"}} /-->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->
Is it possible to assign dynamic values to an attribute? for example
I am trying to use it inside a loop.