WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. clock05
    Member
    Posted 1 year 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:
    <loc>http://url.com/?post_type=wpcf7_contact_form&p=4</loc>

    Any help would be great.

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

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

  5. RyanMasterson
    Member
    Posted 11 months 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.

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

  6. jladams2121@gmail.com
    Member
    Posted 11 months 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
    Member
    Posted 10 months 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
    Member
    Posted 9 months ago #

    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?

  9. jason404
    Member
    Posted 2 months ago #

    @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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic