I’m currently working on a project where I need to display only the first letter of a custom field, je_cct_reviews_reviewer_name, using Bricks Builder’s dynamic data capabilities. I’ve attempted the following methods without success:
**Using the substr Modifier:**I tried the dynamic data tag {je_cct_reviews_reviewer_name:substr:0:1}, but it retrieves the first whole word instead of just the first letter.
**Custom PHP Function with {echo}:**I created a custom function to extract the first letter and used it with the {echo} tag:
Then, I used [first_letter field="je_cct_reviews_reviewer_name"] in Bricks, but still received no output.
Despite these attempts, I haven’t been able to display the first letter as intended. I came across a forum discussion mentioning issues with the {echo} function in Bricks v1.9.1.1, but I’m unsure if it’s related to my situation.
Could anyone provide guidance or alternative methods to achieve this? Any insights would be greatly appreciated.
I guess you can’t use WordPress built-in get_post_meta with JetEngine’s CCT since it’s not posts, just different objects with separated table in database
Thanks @Abd but it’s not working i tried this even shared with bricks support they shared same thing what i’m doing so i replied and now waiting for their reply.
I tried this: {echo:get_first_letter( ‘{je_cct_reviews_reviewer_name}’ )}
Your get_the_first_letter function doesn’t take any parameter, so you can’t use the dynamic data tag {echo:get_first_letter( ‘{je_cct_reviews_reviewer_name}’ )}.
You have to use this dynamic data tag {echo:get_first_letter}, after completing every step as explained in my previous post!
// 1. First create the function
function get_first_letter($name = '') {
// If no name is passed, try to get it from the Bricks context
if (empty($name) && isset($GLOBALS['bricks_loop_context']['je_cct_reviews_reviewer_name'])) {
$name = $GLOBALS['bricks_loop_context']['je_cct_reviews_reviewer_name'];
}
// Get first letter
return !empty($name) ? mb_substr(trim($name), 0, 1) : '';
}
// 2. Then register it with Bricks (what you already have)
add_filter('bricks/code/echo_function_names', function() {
return [
'get_first_letter',
];
});