[SOLVED] Creating Custom Shortcodes that displays content

Hi, I create a shortcode that shows a custom form maded with html, but when i put the shortcode in Pro/cornerstone as a text, blank html… it shows basically the text that says “[shortcodename]”. How can I create a custom shortcode and display all its content in pro? Thanks.

Example:

public function showCalc()
{
	$content = '<div class="wrap"><h1>Hola</h1></div>';
	echo $content;

} add_shortcode('calculadora','showCalc');

And the result:

Need help, thanks!

Hi Jesús,

Are you trying to add the code in the functions.php file of the child theme?

If so, you will get an error if you add the public keyword to the function if the code is not in a class so try just using:

function showCalc()
{
	$content = '<div class="wrap"><h1>Hola</h1></div>';
	echo $content;

} 

add_shortcode('calculadora','showCalc');

I tested this in my setup and it works.

Hope this helps.

1 Like

Thanks Jade

You’re always welcome @xuso15!

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.