Title: HTML Stripping
Last modified: February 28, 2018

---

# HTML Stripping

 *  Resolved [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/)
 * I have a very basic need, which I (almost) solved with some very basic html.
 * The trouble is that when I use this in a product description, the code ends up
   getting reformated as you see in the link provided.
 * It should appear as it does on this page (about 1/2 way down)
    [https://www.coachmansdelight.com/online-learning/live-online-classes/](https://www.coachmansdelight.com/online-learning/live-online-classes/)
 * I’ve tried several form plugins to make a similar dialog, but they are all centered
   on gathering information from the user, rather than providing information. I 
   have not yet found one that just allows this very basic user interface for a 
   simple answer to a common question.
 * What do you suggest?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhtml-stripping-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10026289)
 * Consider making a custom shortcode to output your html. This will bypass the 
   editor filter so you can use whichever tags you need.
 * So your product description would contain: [my_shortcode_name]
 * To give it effect, use:
 *     ```
       <?php
       add_shortcode( 'my_shortcode_name', 'my_function' );
       function my_function() {
       ?>
       <p>my html here</p>
       <?php
       } // end function
       ```
   
 * This code goes in your child theme’s functions.php or you can use the “My Custom
   Functions” plugin.
 *  Thread Starter [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029436)
 * Thanks. This looks like it might help me, but I am getting a syntax error.
 * Here’s what I pasted, yes, leaving ‘my_shortcode’ and so on, which I figured 
   I’d update with real names once I have it working.
 * <?php
    add_shortcode( ‘my_shortcode_name’, ‘my_function’ ); function my_function(){?
   > <p> <html> <body> Classes are held at 9pm Eastern Time. To see what time the
   class will be where you are, select your location below.
 * <form>
    Select Your Location: <select id=”mySelect”> <optgroup label=”United 
   States & Canada”> <option value=”10:30pm”>Newfoundland Time</option> <option 
   value=”10pm”>Atlantic Time</option> <option value=”9pm”>Eastern Time</option>
   <option value=”8pm”>Central Time</option> <option value=”7pm”>Mountain Time</
   option> <option value=”6pm”>Pacific Time</option> </optgroup> <optgroup label
   =”Australia”> <option value=”12pm + 1 day”>Australian Eastern Standard Time</
   option> <option value=”1pm + 1 day”>Australian Eastern Daylight Time</option>
   <option value=”11:30am + 1 day”>Australian Central Standard Time</option> <option
   value=”12:30pm + 1 day”>Australian Central Daylight Time</option> <option value
   =”10am + 1 day”>Australian Western Standard Time</option> </optgroup> <optgroup
   label=”New Zealand”> <option value=”3pm”>New Zealand Daylight Time</option> <
   option value=”3:45pm”>Chatham Daylight Time</option> </optgroup> <optgroup label
   =”Europe”> <option value=”2am + 1 day”>Western European Time</option> <option
   value=”3am + 1 day”>Central European Time</option> <option value=”4am + 1 day”
   >Eastern European Time</option> </optgroup> </select> <button type=”button” onclick
   =”myFunction()”>Show Time</button> <b id=”demo”></b> </form>
 * <script>
    function myFunction() { var x = document.getElementById(“mySelect”).
   value; document.getElementById(“demo”).innerHTML = x; } </script>
 * </body>
    </html>
 * </p>
    <?php } // end function
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029531)
 * Please remove the opening and closing html and body tags. It may not be enough
   to get it working but they’re not right here.
 *  Thread Starter [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029582)
 * Ya, tried that. Didn’t make a difference.
 * I suspect I’m in the wrong place, since the syntax error comes up site-wide.
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029598)
 * Your code works for me. Where did you put the code? This code goes in your child
   theme’s functions.php or you can use the “My Custom Functions” plugin.
 * Wherever, put the whole script, including anything else already in there, here
   to validate it:
    [http://phpcodechecker.com/](http://phpcodechecker.com/)
 * Make sure you are using straight quotes and not smart quotes. It may just be 
   the forum editor but your paste has smart quotes.
 *  Thread Starter [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029675)
 * I’ll double check the smart quotes.
    I’m entering it to Genisis –> Dynamik – 
   Custom Options–> Custom Functions
 * Ok can’t get it past the code checker or the Custom Functions plugin
 *  Thread Starter [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029744)
 * OK, I’ve sorted it out on the functions plugin. Thanks for that tip.
 * Two more questions:
 * Do the “my function” names have to match the “my shortcode” name?
    I’m assuming
   that I replace: function my_function with: function time_check
 * Second;
    I added the shortcode on the second line of text in the content, but
   it shows up in the first line of text.
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029788)
 * 1. Yes.
 * 2. You’ll need to return the html, not print it. The easiest way to do this is
   to open a buffer, make the output, then return the buffer contents:
 *     ```
       function ..
       ob_start();
       ?>
       <p>etc</p>
       <?php
       return ob_get_clean();
       }
       ```
   
 *  Thread Starter [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029798)
 * Is that a second function, or something I put into the first function, or the
   page that I’m adding the shortcode to?
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10029946)
 * No, yes and no respectively.
 *     ```
       add_shortcode( 'my_shortcode_name', 'my_function' );
       function my_function() {
         ob_start();
       ?>
       <p>
       Classes are held at 9pm Eastern Time. To see what time the class will be where you are, select your location below.
   
       <form>
       Select Your Location:
       <select id="mySelect">
       <optgroup label="United States & Canada">
       <option value="10:30pm">Newfoundland Time</option>
       <option value="10pm">Atlantic Time</option>
       <option value="9pm">Eastern Time</option>
       <option value="8pm">Central Time</option>
       <option value="7pm">Mountain Time</option>
       <option value="6pm">Pacific Time</option>
       </optgroup>
       <optgroup label="Australia">
       <option value="12pm + 1 day">Australian Eastern Standard Time</option>
       <option value="1pm + 1 day">Australian Eastern Daylight Time</option>
       <option value="11:30am + 1 day">Australian Central Standard Time</option>
       <option value="12:30pm + 1 day">Australian Central Daylight Time</option>
       <option value="10am + 1 day">Australian Western Standard Time</option>
       </optgroup>
       <optgroup label="New Zealand">
       <option value="3pm">New Zealand Daylight Time</option>
       <option value="3:45pm">Chatham Daylight Time</option>
       </optgroup>
       <optgroup label="Europe">
       <option value="2am + 1 day">Western European Time</option>
       <option value="3am + 1 day">Central European Time</option>
       <option value="4am + 1 day">Eastern European Time</option>
       </optgroup>
       </select> <button type="button" onclick="myFunction();">Show Time</button> <b id="demo"></b>
       </form>
   
       <script>
       function myFunction() {
       var x = document.getElementById("mySelect").value;
       document.getElementById("demo").innerHTML = x;
       }
       </script>
   
       </p>
       <?php
       return ob_get_clean();
       } // end function
       ```
   
 *  Thread Starter [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * (@ampedandy)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10030066)
 * Thanks!

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

The topic ‘HTML Stripping’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)
 * [product description](https://wordpress.org/support/topic-tag/product-description/)

 * 11 replies
 * 2 participants
 * Last reply from: [ampedandy](https://wordpress.org/support/users/ampedandy/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/html-stripping-3/#post-10030066)
 * Status: resolved