it would help a lot to see your function and to know where exactly you are trying to call that function (on a static page? in a template? within a loop?). Did you whitelist the function to be used with the echo tag as described here?
The only thing I can get working it to write my code in a snipit or snipit manager (or functions.php) and then call the function inside a code block (Bricks code element).
Yep, looks like you did not whitelist the my_custom_function. Please check this, and in the function, instead of âechoâ, do a return, just like @aslotta suggested.
We wonât be able to assist if we canât access your site.
Using {echo:} with any element is quite straightforward.
Hereâs a tested solution: Place the following code in your child themeâs functions.php file (make sure the child theme is activated). Also, note that if youâve used this filter in multiple places, the filter results might get overwritten depending on the priority parameter.
add_filter( 'bricks/code/echo_function_names', function() {
return [
'my_custom_function',
];
} );
function my_custom_function() {
return 'Hello from my custom function';
}
Then, use {echo:my_custom_function} on a Basic Text element. You should see âHello from my custom functionâ displayed. If it doesnât render in the builder, make sure the âRender dynamic data text on canvasâ option is enabled.
I followed the video for using âechoâ to call a function and nothing is returned. All code is signed.
Could you also share the URL of the video youâre referring to?
Place the {echo:my_custom_function} in an element (Text)
Run it and let it fail
Go to settings and do the code review
Go back and ass the new echo for the function name in the filter
Sign the code
Save
And then it seems to work. Feels like a LOT of steps to get right to make this work, but I now get it to work sometimes with very simple functions only.
Iâm trying to see where it it failing sometimes and not others - to find just what step I am missing.
there is no code signing involved when using the dynamic echo tag. All you have to do is whitelist the function as mentioned above. The order also shouldnât matter at all.
Well, so far following your kind advice, my functions are working and the data is presenting as expected. Iâm definitely doing things more complex than âHello world!â
I am even using WP Codebox for the code.
Again, thank you everyone for the effort and time to assist.