如何在wordpress中添加批量页面
问题描述:
所以我准备好了一个页面模板。我想制作该页面的2000份副本。页面的样品,你会看到这里如何在wordpress中添加批量页面
hostvento.com/wordpress-hosting.php
我希望像托管等
而且我想在页面替换脚本名的Joomla托管Magento的每个脚本创建页面。这样做的最好方法是什么?
我有我添加了所有页面名称的list.txt文件。
任何插件或shell脚本都可以在这种情况下工作。
答
只是一个粗略的草图,但这样的事情:
$post = get_post(YOUR_BASE_POST_ID)
$file = fopen(YOUR_TXT_FILE_PATH, "r");
while(($line = fgets($file)) !== false):
$handler = $post;
$handler['ID'] = 0;
$handler['post_title'] = $line;
wp_insert_post($handler);
endwhile;
fclose($file);
你可能需要调整一些其他领域或照顾postmeta的...但你的想法;)
我想创建更多的页面,如wordpress托管和页面名称,我保存在list.txt。 。因为我有名称joomla-hosting.php magento-hosting.php opencart-hosting.php –
因此循环遍历你的页面名称,并调用wp_insert_post来创建新页面......? – CBroe
谢谢我现在就试试 –