• Resolved Xaifu

    (@xaifu)


    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

    (@ejcabquina)

    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

    (@xaifu)

    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

    (@ejcabquina)

    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.