I am building a custom query loop from a json object and I am missing some functionalities to easily do the implementation.
add_filter( 'bricks/query/run', function( $results, $query_obj ) {
if ( $query_obj->object_type !== 'my_query_loop_type' ) {
return $results;
}
// Here I have the data in an array format
return [
['name' => 'xxxx', 'url' => '....'],
['name' => 'yyyy', 'url' => '....'],
];
}, 10, 2 );
I like to use the name and the url fields as a dynamic data {name}, {url}
Is there any way I can use the keys of the array as a normal dynamic fields?
Maybe to encapsulate the array in some object so the bricks builder will recognize {name} and {url}
Besides this, does someone knows how internally bricks handles dynamic data, so I better understand it and find a solution for the problem above ?
To answer a part of my question, bricks is checking metadata for the custom fields. So the idea is to alter the default metadata and return the values from the array when needed. Bricks requires the fields to be prefixed with “cf_”.
This will provide the keys from the array prefixed with “cf_” inside the builder in curly brackets, like this (the prefix is handled by Bricks and stripped away when passing to the wordpress funcitons):
The email is: {cf_rest_email}, the name is: {cf_rest_name}
The only thing that I am missing is to insert input fields in the custom loop popup.