【发布时间】:2013-12-23 02:06:49
【问题描述】:
在 WordPress 中有一个功能可以将您的数据导出到 xml 文件中。您可以使用参数点击此 URL,它将开始下载 XML 文件。 cat 参数表示包含要包含在 XML 文件中的帖子的类别的 ID。
问题是我有超过 200 个类别,我想将每个类别导出到单独的文件中。所以必须点击这个网址 http://www.domain.com/wp-admin/export.php?download=true&content=posts&cat=" + [category_num] + "&post_author=0&post_start_date=0&post_end_date=0&post_status=0
在 FOR 循环或类似的东西中
for (i=1; i <= 200; i++) {
hit ("http://localhost/lyricsgroove/wp-admin/export.php?download=true&content=posts&cat="+i+"&post_author=0&post_start_date=0&post_end_date=0&post_ status=0");
}
您可以尝试访问您的 WP 网站 /wp-admin/export.php?download=true&content=posts&cat=1&post_author=0&post_start_date=0&post_end_date=0&post_status=0,您将看到 XML 下载。
我需要做同样的事情,但在循环中。
我尝试在 PHP 中使用 file_get_contents 和在 jQuery 中使用 $.ajax 执行此操作,但它们都没有开始下载。
【问题讨论】:
-
也许你应该在 PHP 中尝试 curl?
-
@Michał 谢谢!我要试试看。
标签: javascript php jquery wordpress