Skip Navigation

[Resolved] Shortcode works but breaks when inside html style attribute

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user is passing a shortcode in php as an html attribute.

Solution:
The reason for this is because wordpress removed support forum shortcodes inside the HTML attributes.

However in our views plugin we made some fixes to allow this to work when its done within our views or content templates.

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Marie 6 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#915261

Hello! Quick note is that I would like to say I am very happy with Toolset and it is truly the best purchase I have made for my website. Thank you!

So, anyway, I am trying to pull an image from a custom field I made for categories (will be used as category header background image, so it is generated automatically in the front end). I use Genesis, and Simple Hooks plugin for Genesis theme.

This is my code, and it is hooked to the header text widget area:

<?php
if ( is_category( $category = '' ) )
{ ?>
<div class="cat-header" style="background-image:url([types termmeta='header-image' output='raw'][/types])">
<div class="cat-title">
<h4>Viewing:</h4>
<h1 style="color:[types termmeta='cat-color'][/types];">[wpv-taxonomy-archive info="name"]</h1>
</div>
</div>
<?php }
?>

Unfortunately, it does not work. However, when I put the types termmeta shortcode outside of the html attribute, it works and displays the raw URL as expected. If you will see in the h1 tag, the types termmeta for cat-color works properly and it displays the text in the color I set originally per category. So I do not understand why the background-image won't work properly. Is there a workaround for this?

I would appreciate the help, thank you so much!

#915374

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Marie,

Thank you for contacting our support forum.

The reason for this is because wordpress removed support forum shortcodes inside the HTML attributes.

However in our views plugin we made some fixes to allow this to work when its done within our views or content templates.

Thanks,
Shane

#915390

Ah, I see, so that is why it worked on my Custom Archives from Views. Then I will find a way to use a View for the header instead. Thank you for the response!