Contact Form 7
[resolved] Google XML Sitemap erroring due to Contact Form 7 (9 posts)

  1. clock05
    Posted 3 years ago #

    I use Contact Form 7 for everything, I just installed Google XML Sitemap, tested it, and receive this error:

    XML Parsing Error: not well-formed
    Location: http://url.com/sitemap.xml
    Line Number 11, Column 73:

    Any help would be great.


  2. Takayuki Miyoshi
    Plugin Author

    Posted 3 years ago #

    This error (from who?) says it is not well-formed, maybe the ampersand should be &amp;, 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.

  3. WebsiteDoctor
    Posted 3 years ago #

    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 http://www.xmlvalidation.com/

    XML Parsing Error: not well-formed
    Location: http://www.domain.com/sitemap.xml
    Line Number 102, Column 68: <loc>http://www.domain.com/?post_type=wpcf7_contact_form&p=1965</loc>

  4. WebsiteDoctor
    Posted 3 years ago #

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

  5. RyanMasterson
    Posted 3 years ago #

    @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?

  6. jladams2121@gmail.com
    Posted 3 years ago #

    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
    Location: http://www.jeffladams.com/sitemap.xml
    Line Number 11, Column 65: <loc>http://www.jeffladams.com/?post_type=wpcf7_contact_form&p=20</loc>

    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.

  7. Bensten
    Posted 3 years ago #

    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" ) )

  8. RyanMasterson
    Posted 3 years ago #

    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?

  9. jason404
    Posted 2 years ago #

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


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic