Title: Executing shortcode inside a html block in GF
Last modified: December 17, 2020

---

# Executing shortcode inside a html block in GF

 *  [josesanchez1984](https://wordpress.org/support/users/josesanchez1984/)
 * (@josesanchez1984)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/executing-shortcode-inside-a-html-block-in-gf/)
 * Hi,
 * I am using WP with Gravtify forms and Twenty20. I would like to execute twenty20
   inside the html block with two variables dynamically generated from user input(
   two images IDs that have already been dynamically uploaded to WP gallery).
 * I tested three different ways:
    1)writing this code on the html field (storing
   JS variables in localStorage) <div id=”slider”></div> <script type=”text/javascript”
   > var id1=localStorage.getItem(“id_1”); var id2=localStorage.getItem(“id_2”);
   var code='[twenty20 img1=”‘+id1+'”‘+’ ‘+’img2=’+'”‘+id2+'”‘+’]’; jQuery(“#slider”).
   html(code); </script> But it only posts “Twenty20 need two images.”
 * 2) writing this code on functions.php (storing id variables in session variable)
   
   echo do_shortcode( ‘[twenty20 img1=”‘. json_decode($_SESSION[“id_images”])[0].‘”
   img2=”‘. json_decode($_SESSION[“id_images”])[1] . ‘]’ ); it works
 * 3) if I just hardcode the shortcode with static IDs on the HTML block it also
   work, I think is due to not understanding whole shortcode with variables on it
 * any help on this? thanks in advance

The topic ‘Executing shortcode inside a html block in GF’ is closed to new replies.

 * ![](https://ps.w.org/twenty20/assets/icon-256x256.png?rev=3241520)
 * [Twenty20 Image Before-After](https://wordpress.org/plugins/twenty20/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/twenty20/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/twenty20/)
 * [Active Topics](https://wordpress.org/support/plugin/twenty20/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/twenty20/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/twenty20/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [josesanchez1984](https://wordpress.org/support/users/josesanchez1984/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/executing-shortcode-inside-a-html-block-in-gf/)
 * Status: not resolved