WordPress.org

Support

Support » Plugins and Hacks » Contact Form 7 » [Resolved] Google XML Sitemap erroring due to Contact Form 7

[Resolved] Google XML Sitemap erroring due to Contact Form 7

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

    @takayukister

    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 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>
    ---------------------------------------------------------------------------------^

    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.

    <url>
    		<loc>http://www.generalkinematics.com/?post_type=wpcf7_contact_form&p=2259</loc>
    		<lastmod>2013-03-11T20:59:08+00:00</lastmod>
    		<changefreq>weekly</changefreq>
    		<priority>0.8</priority>
    	</url>

    @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
    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&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” ) )

    Bensten,
    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?

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

    http://wordpress.org/support/topic/sitemaps-not-working

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