Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 在wordPress中自动动态创建页面_Database_Wordpress_Layout_Plugins_Automation - Fatal编程技术网

Database 在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

有没有一种简单的方法可以在wordPress中自动、动态地创建页面?让我进一步解释: 我正在开发一个网站,我有20多个相同的页面,布局相同,其中只有3个数据字段发生变化: 图像,描述,如何做。 例如,有没有办法在表格中输入数据,然后wordpress自动创建页面?
谢谢。

您可以尝试使用以下代码-

$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'
        )
    );
}