Title: Problem with Gutenberg escaping shortcode attributes
Last modified: July 13, 2021

---

# Problem with Gutenberg escaping shortcode attributes

 *  Resolved [Xaifu](https://wordpress.org/support/users/xaifu/)
 * (@xaifu)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-gutenberg-escaping-shortcode-attributes/)
 * Hi
 * I’ve found a problem with the Gutenberg shortcode block and it affects to Wp 
   Show Posts attributes in shortcode.
 * I’m using Wp Show Posts shortcode like this:
 * `[wp_show_posts id="76440" settings="taxonomy=category&tax_term=category_1"]`
 * I haven’t detected when exactly does it happen but sometimes the ampersand character
   gets escaped and changes to & so the shortcode stops working as expected.
 * It’s weird because it doesn’t happen always. I mean the shortcode works correctly
   at first and I can edit and save the page several times and the & character isn’t
   escaped.
 * Then all of a sudden it changes all ampersand characters in all the shortcode
   blocks I have in the same page. And even though I recover a previous revision,
   the escaped character persists until I edit all shortcodes and save the page.
 * Searching Google it seems that this is a problem with html and shortcode block.
   Do you know a fix for this or another way to avoid it? or any way to make wp 
   show posts use the escaped character as well as the original?

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

 *  Plugin Support [Elvin](https://wordpress.org/support/users/ejcabquina/)
 * (@ejcabquina)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-gutenberg-escaping-shortcode-attributes/#post-14658065)
 * Hi there,
 * Something seems to be escaping the contents of your shortcode blocks.
 * Can’t be exactly sure what it is but can you try to disable ALL plugins except
   WPSP and check w/c one is causing it?
 * If you have PHP snippets from child theme’s functions.php or from a Code snippets
   plugin, can you try disabling them well?
 * Or you can just do this:
 * You can create your own shortcode to avoid using shortcode atts, meaning you 
   can avoid using characters like `&` in it.
 * Check this PHP snippet –
 *     ```
       add_shortcode('wrapped_wpsp', function($atts){
           $atts = shortcode_atts( array(
       			'id' => '',
                   'taxonomy' => '',
                   'term' => ''
       		), $atts, 'wrapped_wpsp' );
   
           $settings = array(
               'taxonomy' => $atts['taxonomy'],
               'tax_term' => $atts['term'],
           );
   
           ob_start();
           wpsp_display( $atts['id'], $settings );
           return ob_get_clean();
       });
       ```
   
 * With this, you can do shorcode `[wrapped_wpsp id="1234" taxonomy="category" term
   ="category_1"]`
 *  Thread Starter [Xaifu](https://wordpress.org/support/users/xaifu/)
 * (@xaifu)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/problem-with-gutenberg-escaping-shortcode-attributes/#post-14658859)
 * The php snippet you provided has saved me!
 * Also, now the shortcode is cleaner and easier to edit for my client.
 * Thank you very much for your help!
 *  Plugin Support [Elvin](https://wordpress.org/support/users/ejcabquina/)
 * (@ejcabquina)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/problem-with-gutenberg-escaping-shortcode-attributes/#post-14662930)
 * No problem. Glad to be of any help. 😀

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

The topic ‘Problem with Gutenberg escaping shortcode attributes’ is closed to new
replies.

 * ![](https://ps.w.org/wp-show-posts/assets/icon-256x256.png?rev=2846296)
 * [WP Show Posts](https://wordpress.org/plugins/wp-show-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-show-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-show-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-show-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-show-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-show-posts/reviews/)

## Tags

 * [ampersand](https://wordpress.org/support/topic-tag/ampersand/)

 * 3 replies
 * 2 participants
 * Last reply from: [Elvin](https://wordpress.org/support/users/ejcabquina/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/problem-with-gutenberg-escaping-shortcode-attributes/#post-14662930)
 * Status: resolved