Database 在wordPress中自动动态创建页面
有没有一种简单的方法可以在wordPress中自动、动态地创建页面?让我进一步解释: 我正在开发一个网站,我有20多个相同的页面,布局相同,其中只有3个数据字段发生变化: 图像,描述,如何做。 例如,有没有办法在表格中输入数据,然后wordpress自动创建页面?Database 在wordPress中自动动态创建页面,database,wordpress,layout,plugins,automation,Database,Wordpress,Layout,Plugins,Automation,有没有一种简单的方法可以在wordPress中自动、动态地创建页面?让我进一步解释: 我正在开发一个网站,我有20多个相同的页面,布局相同,其中只有3个数据字段发生变化: 图像,描述,如何做。 例如,有没有办法在表格中输入数据,然后wordpress自动创建页面? 谢谢。您可以尝试使用以下代码- $check_page_exist = get_page_by_title('title_of_the_page', 'OBJECT', 'page'); // Check if the page al
谢谢。您可以尝试使用以下代码-
$check_page_exist = get_page_by_title('title_of_the_page', 'OBJECT', 'page');
// Check if the page already exists
if(empty($check_page_exist)) {
$page_id = wp_insert_post(
array(
'comment_status' => 'close',
'ping_status' => 'close',
'post_author' => 1,
'post_title' => ucwords('title_of_the_page'),
'post_name' => sanitize_title('title_of_the_page'),
'post_status' => 'publish',
'post_content' => 'Content of the page',
'post_type' => 'page',
'post_parent' => 'id_of_the_parent_page_if_it_available'
)
);
}