facetwp_builder_dynamic_tags
Overview
This filter lets you generate your own Layout Builder dynamic tags.
Parameters
- $tags | array | An associative array of tags and their values
- $params | array | An associative array of extra data (see below)
$tags = [ 'post:id' => $post->ID, 'post:name' => $post->post_name, 'post:type' => $post->post_type, 'post:url' => get_permalink() ];
$params['layout'] // the raw layout data for this template $params['post'] // the current post
Usage
Example 1: create a dynamic tag from an ACF field named first_name
:
add_filter( 'facetwp_builder_dynamic_tags', function( $tags, $params ) { $tags['acf:first_name'] = get_field( 'first_name', $params['post']->ID ); return $tags; }, 10, 2 );
Then within the Layout Builder, you’d use {{ acf:first_name }}