Title: Inserting icon before str replace
Last modified: February 28, 2020

---

# Inserting icon before str replace

 *  Resolved [donahmar](https://wordpress.org/support/users/donahmar/)
 * (@donahmar)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/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 } ?>

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

 *  [Tim Nolte](https://wordpress.org/support/users/tnolte/)
 * (@tnolte)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/inserting-icon-before-str-replace/#post-12493062)
 * [@donahmar](https://wordpress.org/support/users/donahmar/) my first recommendation
   is that you really shouldn’t be storing HTML in the status field. There should
   be frontend/presentation code that adds that elsewhere based on the values. What
   plugin are you importing data into that has a field called `productsupportstatus`?
 * The other thing is that with the function editor the expectation is that it is
   taking the input into a function and the function is returning the value. [This documentation page](https://www.wpallimport.com/documentation/developers/custom-code/inline-php/)
   gives you some examples of how that works.
 *  Thread Starter [donahmar](https://wordpress.org/support/users/donahmar/)
 * (@donahmar)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/inserting-icon-before-str-replace/#post-12493095)
 * `productsupportstatus` is a column in the file I am importing — not a field or
   plugin.
    I am not importing the `productsupportstatus` as HTML, I am just trying
   to append a span to the values so it displays an icon.
 * However, it sounds like the Function Editor is how I will get it done. Now I 
   have to learn PHP lol. Thanks [@tnolte](https://wordpress.org/support/users/tnolte/)!
 *  [Tim Nolte](https://wordpress.org/support/users/tnolte/)
 * (@tnolte)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/inserting-icon-before-str-replace/#post-12493683)
 * [@donahmar](https://wordpress.org/support/users/donahmar/) inserting the span
   tag is HTML. Since I don’t have the full picture of what type of post this is
   creating I can’t provide a better alternative but it just seems like there might
   be a better way of accomplishing what you are doing. Since I’m on my phone it’s
   a little bit harder for me to provide you with some code for the function. When
   I have a chance to get in my computer I can get something written.
 *  Thread Starter [donahmar](https://wordpress.org/support/users/donahmar/)
 * (@donahmar)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/inserting-icon-before-str-replace/#post-12499900)
 * I solved it with the following:
 * //in content area
 *     ```
       [setIcon({productsupportstatus[1]})]
       //in Function Editor
       <?php
       	function setIcon($productsupportstatus){
       		$productsupportstatus = str_replace('Not Supported', '<span class="blue-icon"></span> Contact Us',$productsupportstatus);
       		$productsupportstatus = str_replace('Supported', '<span class="green-icon"></span> Supported',$productsupportstatus);
       	return $productsupportstatus;}
       ?>
       ```
   
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/inserting-icon-before-str-replace/#post-12505018)
 * Thanks for updating us [@donahmar](https://wordpress.org/support/users/donahmar/)–
   your solution looks good!

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

The topic ‘Inserting icon before str replace’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/inserting-icon-before-str-replace/#post-12505018)
 * Status: resolved