Title: Embed Shortcode in HTML Tag
Last modified: August 30, 2016

---

# Embed Shortcode in HTML Tag

 *  Resolved [wordpressfanboy](https://wordpress.org/support/users/wordpressfanboy/)
 * (@wordpressfanboy)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/embed-shortcode-in-html-tag/)
 * Hello Eliot,
 * thank you for that great plugin, helps us a lot here.
 * I used to be able to embed your shortcodes directly into html-tags before (I 
   need it to generate a class for a div in a loop). Example:
 * [loop parent=this]
    <div class=”[pass field=”id”][myOwnShortcode]{ID}[/myOwnShortcode][/
   pass]”> </div> [/loop]
 * So since some recent updates of wordpress and plugins this won’t work anymore.
   It does work outside / between the html tags as it should, but not embedded in
   the tags.
 * I am not sure if it was ever supposed to, but is there some workaround for this?
 * Thank you,
 * Andreas
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/embed-shortcode-in-html-tag/#post-6624306)
 * Hi Andreas,
 * Since WP 4.2.3, shortcodes in HTML attributes are handled more strictly. Part
   of that change is about “quotes”, so the above code might work if you change 
   this part: `[pass field=id]` – the use of double quotes inside double quotes 
   is probably the problem.
 * Another thing I just noticed, when you use the _field_ parameter for pass, the
   tag you want is `{FIELD}`. It’s a bit confusing: when using the _fields_ parameter(
   with an “s”), then the tags are uppercased versions of field names. This feature
   can be used from the loop directly too. So you might try:
 *     ```
       [loop parent=this fields=id]
       <div class="[myOwnShortcode]{ID}[/myOwnShortcode]">...</div>
       [/loop]
       ```
   
 *  Thread Starter [wordpressfanboy](https://wordpress.org/support/users/wordpressfanboy/)
 * (@wordpressfanboy)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/embed-shortcode-in-html-tag/#post-6624416)
 * Hi Eliot,
 * thank you so much for you reply. Your hint to the newly strict shortcode handling
   by wordpress did it. As explained in
 * > [Changes to the Shortcode API](https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/)
 * I decided to return the whole <div> including styling and classes by my shortcode
   function, and now it works! 🙂
 * Cheers, Andreas
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/embed-shortcode-in-html-tag/#post-6624421)
 * Yes, that sounds like the best solution. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Embed Shortcode in HTML Tag’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/embed-shortcode-in-html-tag/#post-6624421)
 * Status: resolved