Inserting icon before str replace
-
Hello,
I am importing a column called productsupportstatus – values are “Supported” or “Not Supported”.I successfully used this string to replace “Not Supported” with “Contact Us”.
[str_replace(“Not Supported”, “Contact Us”, {productsupportstatus[1]})]Now I want to add a green icon in front of “Supported” and a blue icon in front of “Contact Us” using my theme’s icon font. I am trying to do this by adding a span in the string above, but it isn’t working. I was going to use CSS to change the colors. WP All Import isn’t allowing me to add a span in the string (inside the content text editor), and I don’t know PHP yet to successfully write a PHP script in the function editor.
Can someone help? This is what I have for inline PHP & CSS
[str_replace(“Not Supported”, “<span class=”blue-icon”></span>Contact Us”, {productsupportstatus[1]})][str_replace(“Supported”, “<span class=”green-icon”></span>Supported”, {productsupportstatus[1]})]
.blue-icon:before {
content: “\e034”; //this is from Divi’s icon library
font-size: 64px;
color: blue;
font-family: ‘ETmodules’
}.green-icon:before {
content: “\e034″; //this is from Divi’s icon library
font-size: 64px;
color: green;
font-family: ‘ETmodules’
}This is what I tried in the Function Editor
<?php
if($productsupportstatus===’Supported’) {
?>
<span class=”green-icon”></span>
<?php
}
?><?php
if($productsupportstatus===’Not Supported’) {
//maybe this should be the new value of ‘Contact Us’?
?>
<span class=”blue-icon”></span>
<?php
}
?>
The topic ‘Inserting icon before str replace’ is closed to new replies.