• Having a bit of a weird issue. I’m trying to set inline style with CCS but it seems values aren’t returned at all. Example:

    [related field_name] 
    <div class="box" style="background:[taxonomy level field=level_color];"><h2>content</h2></div>
    [/related]

    This does not work. I’ve tried double brackets and '' etc. I’ve checked and values do get returned outside the inline style.

    I’ve also used a Beaver Builder post module, which lets you create custom post layouts with HTML. In essence it’s basically a loop. Inside I’ve set the same style settings as above but in there, they work fine.

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

    (@miyarakira)

    I believe this is due to the shortcode being in an HTML attribute, which is treated differently when it’s in a post content. In this case, the taxonomy shortcode is being run before related.

    There’s a workaround to use double brackets, like [[ and ]], for shortcodes inside HTML attribute. Could you try that and see if that solves it?

    Thread Starter finnfin

    (@finnfin)

    Thanks!
    Yeah I actually tried that because I ran into the issue before. But it doesn’t help in this case. It does help in some cases, but doesn’t seem to when inside inline css.

    Like I mentioned, it works when using a Beaver Builder posts module. There I don’t need to use the [related] loop because the module itself does the looping. So what you suggested would suggest it should work, but I’m not sure why it doesn’t.

    You can use [pass] to insert stuff in HTML attributes.

    [related field_name] 
    [set myvar][taxonomy level field=level_color][/set]
    [pass vars]
    <div class="box" style="background:{MYVAR};"><h2>content</h2></div>
    [/pass]
    [/related]
    • This reply was modified 3 years, 6 months ago by polarracing.
    Thread Starter finnfin

    (@finnfin)

    Thanks! I had tried that too but was stupidly missing the [/pass]. Thanks for the help again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Inline style and CCS’ is closed to new replies.