Solution to the problem that the wordpress sitemap.xml generation plug-in does not support custom article types

WordPress plug-in , WordPress Tutorial two thousand four hundred and twenty-two

Many wordpress Chinese sites use Baidu Sitemap Generator, a Baidu map generation plug-in in Liucheng, to generate Baidu sitemap sitemap.xml files. Although the plug-in has not been updated for a long time, it can still be used normally, but it does not support wordpress's user-defined article types, However, most themes now use wordpress custom article types to manage some special content, such as products, photo albums, etc. This leads to that when submitting URLs to Baidu, the URLs of these content will not appear in the sitemap.xml file, which will affect Baidu's collection of websites to some extent.

Now it is obviously not timely for the author to update the plug-in, but he can modify the plug-in himself, and it is very simple.

Operation steps

1. After installing the plug-in, edit the wp content/plugins/baidu sitemap generator/baidu_sitemap. php file, and find the code in line 174: (or search the following code directly)

 one
 AND ( post_type = 'post' or post_type = 'page' )

Modify to

 one
 AND ( post_type = 'post' or post_type = 'page' or post_type = 'product' )

Tip: If you want to add multiple custom article types, add multiple or post_type='product' , of which product It is the name of the user-defined article type, which can be replaced with the corresponding user-defined article type name.

2. Continue to find the code at line 318:

 one
 AND post_type = 'post'

Modify to

 one
 AND ( post_type = 'post' or post_type = 'product' )

Tip: Same as step 1, add as many as possible or post_type='product' , and then change the name respectively.

3. After saving the changes, re update the xml file in the background (that is, click the Update XML file button)

Plug in download

Since the plug-in has not been updated for a long time, WordPress has officially hidden the download address. If you need to download it, you can directly visit the following address to download it. After the blog bar tests, it can still be downloaded until this article is released.

Download address: https://downloads.wordpress.org/plugin/baidu-sitemap-generator.zip

Highlight: