Short codes aren't working

Trying to use a custom short code but it’s not working. I tested this short code in another wordpress installation and it worked as expected. Hope you can help with this. Thanks.

Hey @brocknessmonster,

Thanks for reaching out!

I have verified the shortcode on my end, and it is functioning properly. This indicates that the issue may be due to a plugin or custom code conflict within that installation. Please review the troubleshooting procedures.

Hope that helps.

I went through that linked article. Did not find the cause of the short code issue.

Thank you for the info.

Instead of using the shortcode, try using a Twig template. We created a test page. Please check the link in the secure note.

<p>{% set length = 10 %}<br />
{% set characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' %}<br />
{% set random_string = '' %}</p>
<p>{% for i in 1..length %}<br />
{% set random_string = random_string ~ random(characters) %}<br />
{% endfor %}</p>

<form><input value="{{random_string}}" type="text" /></form>
1 Like

Thanks for that suggestion. I found what was creating the issue with my short code and fixed it.

Hey @brocknessmonster,

We’re glad that you’re able to figure it out!

Thank you.

Here’s the weird thing: the short code works when placed in a P tag. However if I try to use the short code with a value of an input it fails.

This works
<p>[random_code]</p>

but this doesn’t
<input type="text" value=" [random_code]" >

Hi @brocknessmonster,

The shortcode returns the printed value and that is why it shows the value while used in the p tag. But while using inside the input tag it may be printing the value, but may not be showing. Please check the code using the browser inspector or in the view source.

NOTE: Please don’t use the shortcode inside the input element.

Thanks

Why not use the short code inside input value?

Hey @brocknessmonster,

WordPress only processes shortcodes when they’re part of the content that goes through the shortcode parser (typically in post content or widget areas). When you put a shortcode inside an HTML attribute—like the value attribute of an input element—it isn’t parsed, so you’ll just see the literal text [random_code].

With that said, Twig is the best way to do this if you want a Cornerstone integration. Just follow the recommendation from my colleague @Ismael.

Hope that helps.

1 Like

thanks for taking the time to explain that :+1:

Hey @brocknessmonster,

You’re most welcome!

1 Like

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