gb_get_field()
This method allows you to retrieve Block metadata programmatically.
Experimental Feature @since v1.0.0-RC4.2.0
A GutenBricks block can store meta value. If you're using ACF or Metabox fields to create input fields, their values are saved within the block. The values are retrieve as dynamic data in Bricks (For eg. {acf_example}
)
Sometimes, the code editor you're working on may not support dynamic data or has no access to meta data saved in Blocks. For example, the PHP editor inside Bricks Builder's Query Loop does not access Block meta data.
In this case, you can use gb_get_field($key, $post_id, $args)
function to retrieve the value instead.
This method works for both ACF and Metabox.
The retrieving hierarchy:
First, it will look for data stored within the block
If not, it returns the value saved on other related sources such as page or template
Example:
get_gutenbricks_meta($key, $post_id, $args)
$key (required): key value that you would use inside Bricks builder to retrieve the dynamic data. You will need acf_
and mb_bricks_template_
prefixes for them
$post_id (optional): Post, page or CPT where you want to retrieve the data from
$args (optional): $arg parameter for Metabox's rwmb_get_value(). Ignored when the dynamic data is from ACF.
Last updated