• Resolved ulissse

    (@ulissse)


    Hello,

    I have microdata (Structured Data) on my website, and the AMP plugin correctly add it within the amp post but it automatically add <![CDATA[ just after the first line like this :

    ” <script type=”application/ld+json”><![CDATA[ ”

    This additional tag added by AMP plugin cause a syntax error on Google that completely block all my structured data.

    Can someone tell me how to remove this tag ?

    Thank you for your help.

    • This topic was modified 8 years, 3 months ago by ulissse.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter ulissse

    (@ulissse)

    Ok, here is a little more information about my trouble :

    In fact, i had 2 schema scripts, one from my rating pluging and the other from the AMP plugin.

    I have removed the structured data of the AMP plugin because it was not complete so i’m now with the structured data of the rating plugin but still can’t found how to remove the annoying tag <!CDATA[“”].

    I hope someone can help me out with that.

    ps: sorry for my bad English 🙁

    Fixed In The Next Version

    Hi @ulissse,
    Thanks for raising this, and we’ve also seen this issue 🙂

    There’s a fix for this in the upcoming 0.7 release:

    https://github.com/Automattic/amp-wp/tree/0.7

    It’s now in Beta, and we’d appreciate you testing it if you can. But it’s not yet ready for a production site.

    Here’s the pull request that fixed the issue:
    https://github.com/Automattic/amp-wp/pull/891

    Thanks!

    Thread Starter ulissse

    (@ulissse)

    That’s great to hear, thank you, but in the meantime of the new release of the plugin is there a way to remove this CDATA ?

    For exemple by adding something like this on the right place :

    $string = str_replace(‘<![CDATA[‘,”,$string);
    $string = str_replace(‘]]>’,”,$string);

    Thank you.

    Plugin Author Weston Ruter

    (@westonruter)

    You could try something like this:

    add_filter( 'amp_post_template_data', function( $data ) {
        $data['post_amp_content'] = str_replace( '<![CDATA[', '', $data['post_amp_content'] );
        $data['post_amp_content'] = str_replace( ']]>', '', $data['post_amp_content'] );
        return $data;
    } );
    Thread Starter ulissse

    (@ulissse)

    This is working great!

    Thank’s a lot, i have all my problems solved.

    Thanks again for you great work !

    Plugin Author Weston Ruter

    (@westonruter)

    Thanks! By the way, there haven’t been a lot of plugin ratings submitted to coincide with the recent improvements to the plugin. If you wouldn’t mind adding a review that would be helpful: https://wordpress.org/support/plugin/amp/reviews/#new-post

    Thread Starter ulissse

    (@ulissse)

    Done. 🙂

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

The topic ‘<![CDATA[ tag block structured data’ is closed to new replies.