Support » Plugin: Contact Form 7 » Google XML Sitemap erroring due to Contact Form 7

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Takayuki Miyoshi


    This error (from who?) says it is not well-formed, maybe the ampersand should be &, so nothing tells that it is due to Contact Form 7. You should ask the developer of Google XML Sitemap to fix it, instead. In the first place, it shouldn’t output the URL of non-public post type like wpcf7_contact_form into the sitemap XML.

    I’ve encountered this error also, it presents in Google Webmaster tools, in the browser if viewing the XML directly, and in the XML validator if tested there

    XML Parsing Error: not well-formed
    Line Number 102, Column 68: <loc></loc>

    Successful workaround is to postid to exclude list in sitemap plugin.

    @takayuki – It may not be a problem with Google XML Sitemaps. I’m using a different plugin for my XML sitemap — Yoast’s WordPress SEO — but and I’m having the exact same problem.


    @websitedoctor, I didn’t understand your workaround. Can you please elaborate?

    I had the Google XML Sitemap plugin installed and working correctly. I then installed the Contact Form 7 plugin. When this happened, I got the following error in my sitemap:

    XML Parsing Error: not well-formed
    Line Number 11, Column 65: <loc></loc&gt;

    When I deactivate the Contact Form 7 plugin again, the error goes away. Please help me fix this – I also do not understand the workaround suggested by WebsiteDoctor.

    You have to add some lines to the plugin to exclude the Contact-Form links.

    Now take a look at the plugin (plugin editor in your dashboard):

    At the bottom you will find the following code snippet:

    if ( ! empty( $post->post_title ) ) {
      $xml .= "\t<url>\n";
      $xml .= "\t\t<loc>" . get_permalink( $post->ID ) . "</loc>\n";
      $xml .= "\t\t<lastmod>" . mysql2date( 'Y-m-d\TH:i:s+00:00', $post->post_modified_gmt, false ) . "</lastmod>\n";
      $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
      $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
      $xml .= "\t</url>\n";

    Just change the if-Statement to:
    if ( ! empty( $post->post_title ) && ( get_post_type( $post->ID ) != “wpcf7_contact_form” ) )

    Thanks, that makes sense for Google XML Sitemaps. However Yoast WordPress SEO’s code to generate XML sitemaps is different — it doesn’t use post_title in the conditional. Can you make a recommendation for that?

    Did you ever find out the problem? I am having the same issue with WordPress SEO by Yoast.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Google XML Sitemap erroring due to Contact Form 7’ is closed to new replies.