我正在使用wp_insert_post
以编程方式向网站添加内容。这适用于帖子、类别和标签,但不适用于页面。
当我尝试添加页面(即post\\u type=page的post)时,重写规则无法正确重新生成(或者在wp_insert_post
). 具体而言,与类别和标记URL相关的规则会丢失,如下所示:
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
。。。等这意味着标记和类别存档URL会被破坏。只需单击设置>永久链接即可修复它们。已尝试使用修复$wp_rewrite->flush_rules()
紧接着wp_insert_post
但这并没有解决问题。。。