Integrating the Google Places API into your WordPress site can significantly enhance your content by displaying detailed information about specific locations. Bricks Builder, a powerful visual page builder for WordPress, provides a user-friendly way to incorporate this data into your site. This blog post will guide you through the process of displaying Google Place data using Bricks Builder and the Google Places API.
First, place this code to functions.php file or code snippet plugin. Make sure you have enable Google Place Api and Have a Place ID which you can get from this
We can return the data from array as a string using this function.
function my_echo_place_info($field) {
$info = my_get_place_info();
if (is_array($info) && isset($info[$field])) {
if ($field == 'weekday_text' && is_array($info[$field])) {
$output = '<ul>';
foreach ($info[$field] as $day) {
$output .= '<li>' . esc_html($day) . '</li>';
}
$output .= '</ul>';
return $output;
} else {
return esc_html($info[$field]);
}
}
return 'Invalid field or no data available';
}Last step is to allow the function to be executed as a dynamic data.
add_filter( 'bricks/code/echo_function_names', function($function_name) {
return [
'@^my_', // Allow all functions that start with "brx_"
];
} );This method is not exclusive to Bricks Builder user, you can use this for any wordpress environment.

