james
1
Bricks Version: 1.4 RC2
Browser: Chrome 90
OS: macOS.
URL: (a link to a page that illustrates the issue would be really helpful)
If I put a custom shortcode inside a Rich Text or Shortcode element then the echo’d text is output in the source code before the element.
e.g. The table below is echo’d from a shortcode in my functions.php file. The text is before the element and the element itself is empty.

james
2
This is also happening on the Related Posts element if I enter a shortcode into one of the content fields.


Hi James,
Thanks so much for your report!
Unfortunately, I am not able to reproduce the issue. Are you sure there are no issues within your shortcode function?
Can you please test it again with this simple example and see if it works?
function demo_shortcode() {
$message = 'Hello James!';
return $message;
}
add_shortcode('greeting', 'demo_shortcode');
[greeting]
Best regards,
timmse
james
4
Apologies, my fault I was echo’ing rather than returning the string! Sorry for wasting your time
timmse
5
No problem, you’re welcome 
Hi James! Im getting the same issue. How do you return a string?
james
7
@fmkaizen Instead of echoing the string like this:
function demo_shortcode() {
$message = 'Test';
echo $message;
}
return the string, don’t use echo:
function demo_shortcode() {
$message = 'Test';
return $message;
}
1 Like