• Resolved wordpressfanboy

    (@wordpressfanboy)


    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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    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

    (@wordpressfanboy)

    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

    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

    (@miyarakira)

    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.