wordpress使用站点地图插件,报错:XML declaration allowed only at the start of the document

  • A+
所属分类:WordPress

新站为了使自己的网站快速收录,都会为自己的站点建立站点地图(sitemap),sitemap其实就是一个包含了你网站中所有url链接的文件,可以是xml文件,也可以是其他格式的文件,我这里弄好之后,其他是xml文件嵌套着xml文件,如图所示。但是搜索引擎对站点地图文件进行爬虫时,会将嵌套的xml全部进行爬取,因此,不用担心会遗漏url。

wordpress使用站点地图插件,报错:XML declaration allowed only at the start of the document

搜索引擎爬取时会及时反馈结果,爬取sitemap的速度很快,一般提交后10分钟即可看到结果,如下图。

wordpress使用站点地图插件,报错:XML declaration allowed only at the start of the document

上图的url是发给搜索引擎的站点地图url,爬取后左边出现了文件夹图标,说明,该xml里面嵌套着其他xml文件,后面“提取url数量”是嵌套的xml数量,点击进去后发现

wordpress使用站点地图插件,报错:XML declaration allowed only at the start of the document

其实这里才是搜索引擎真正爬取到url的xml文件,后面的“提取url数量”的总和就是你网站所有可用url的数量。

为自己的网站生成站点地图,推荐使用插件:Google XML Sitemaps。但是我在使用Google XML Sitemaps生成站点地图xml的时候,遇到了问题

wordpress使用站点地图插件,报错:XML declaration allowed only at the start of the document

这个问题我看到后觉得很奇怪,后来发现xml文件的第一行多了几个空格,应该就是这个空格的原因,于是我百度了一些方法,将可行办法记录下来。

  1. 修改网站根目录下wp-blog-header.php文件
  2. 在$wp_did_header = true;下方添加:ob_start(); ,
  3. 在wp();前面添加:ob_end_clean();
  4. ok,刷新站点地图网址,大功告成
Qt大课堂-QtShare

发表评论

您必须登录才能发表评论!

目前评论:1   其中:访客  1   博主  0

    • avatar Dannygoast 0

      Gеt uр to $ 20,000 реr daу with our рrоgrаm.
      Wе аre а tеam оf еxрeriеncеd рrоgrаmmеrs, wоrkеd mоrе than 14 months оn this program and nоw еvеrything is rеаdy and evеrything works рerfеctly. The PayРal systеm is verу vulnеrаblе, instеаd оf notifуing thе devеlopers of PауРаl about this vulnerаbilitу, we took advаntagе оf it. Wе аctivеly usе оur рrogram fоr pеrsonal enriсhment, tо shоw hugе amоunts of mоnеу оn our acсоunts, wе will nоt. уou will nоt bеliеve until you try and аs it is nоt in оur interеst to рrоve tо you thаt something is in yours. When wе rеаlized thаt this vulnеrаbility can be used massively withоut cоnsequences, wе dесided to helр the rеst оf the реоple. We dеcided nоt to inflаte the рriсe of this gold prоgram аnd put a vеry lоw priсe tag, only $ 550. In оrder fоr this prоgrаm tо be аvаilаblе to a lаrge number of peорle.
      All the dеtаils оn our blоg: http://onlinemanuals.txdot.gov/help/urlstatusgo.html?url=https://www.pinterest.com/pin/690387817853172742/