Title: Error when using the strip HTML filter
Last modified: May 3, 2019

---

# Error when using the strip HTML filter

 *  Resolved [bt_dev](https://wordpress.org/support/users/biotrace/)
 * (@biotrace)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/error-when-using-the-strip-html-filter/)
 * Hi there – I am using the strip HTML filter but when generating the feed, the
   plugin will return an error after “processing” a while.
 * We are using the following code and version 1.13.1:
 *     ```
       function strip_tags_from_short_description( $attributes, $feed_id, $product_id ) {
       	$attributes['description'] = strip_tags( $attributes['description'] );
       	return $attributes;
       }
   
       add_filter( 'wppfm_feed_item_value', 'strip_tags_from_short_description' );
       ```
   

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

 *  Plugin Contributor [Michel Jongbloed](https://wordpress.org/support/users/michel-jongbloed/)
 * (@michel-jongbloed)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/error-when-using-the-strip-html-filter/#post-11497785)
 * Hello [@biotrace](https://wordpress.org/support/users/biotrace/),
 * Just to make sure it its the code that is causing the issue, could you try to
   deactivate it and see if you then can generate the feed again?
 * If the feed still keeps hanging in the processing mode, please try the steps 
   from this FAQ list: [https://www.wpmarketingrobot.com/support/faq/#toggle-id-16](https://www.wpmarketingrobot.com/support/faq/#toggle-id-16)
 *  Thread Starter [bt_dev](https://wordpress.org/support/users/biotrace/)
 * (@biotrace)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/error-when-using-the-strip-html-filter/#post-11498812)
 * Hi Michel,
 * I can confirm the feed only hangs when the filter is activated.
 * I followed all the steps in the FAQ list you supplied and none of the suggestions
   resolved the issue.
 * When the code filter is active, the browser console returns the error:
    POST 
   500 – [https://XXXXX/wp-admin/admin-ajax.php](https://XXXXX/wp-admin/admin-ajax.php)–
   load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&
   ver=4.9.8:4
 *  Plugin Contributor [Michel Jongbloed](https://wordpress.org/support/users/michel-jongbloed/)
 * (@michel-jongbloed)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/error-when-using-the-strip-html-filter/#post-11501326)
 * OK, I tested the code and it seems to work alright on my system.
 * The function description of strip_tags states the following warning: Because 
   strip_tags() does not actually validate the HTML, partial or broken tags can 
   result in the removal of more text/data than expected.
 * So could it be that one of the descriptions is generating an html error when 
   stripped?
 * Could you perform a feed generation that fails and then check the feed file to
   see what product was added last to the file, then check if the next product has
   something strange in its description?
 * Could you also try to generate a feed using only one category and if that works,
   see if you can single out any category that contains a failing product?
 * Also, could you try alternatives for the strip_tags() function, like wp_filter_nohtml_kses()
   or even use the following line?
 * `$attributes['description'] = preg_replace ('/<[^>]*>/', ' ', $attributes['description']);`
 * I know this does not give the same results, but it’s just meant to check.
    -  This reply was modified 7 years, 1 month ago by [Michel Jongbloed](https://wordpress.org/support/users/michel-jongbloed/).
 *  Thread Starter [bt_dev](https://wordpress.org/support/users/biotrace/)
 * (@biotrace)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/error-when-using-the-strip-html-filter/#post-11506694)
 * Hi Michel,
 * Using the preg_replace function with the suggested line worked perfectly. The
   full code snippet used is:
 *     ```
       function alter_feed_item( $attributes, $feed_id, $product_id ) {
   
       	$attributes['description'] = preg_replace("/<[^>]*>/", "", $attributes['description'] );
   
       	// IMPORTANT! Always return the $attributes
       	return $attributes;
       }
   
       add_filter( 'wppfm_feed_item_value', 'alter_feed_item', 10, 3 );
       ```
   
 * Thanks for your help!

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

The topic ‘Error when using the strip HTML filter’ is closed to new replies.

 * ![](https://ps.w.org/wp-product-feed-manager/assets/icon-256x256.png?rev=3208464)
 * [WPMR Google Feed Manager for WooCommerce – Sell on Google Merchant Center & Shopping](https://wordpress.org/plugins/wp-product-feed-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-product-feed-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-product-feed-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-product-feed-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-product-feed-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-product-feed-manager/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [bt_dev](https://wordpress.org/support/users/biotrace/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/error-when-using-the-strip-html-filter/#post-11506694)
 * Status: resolved