首页 > 解决方案 > 使用 wp_insert_post 将页面内容设置为 Elementor 模板

问题描述

我想使用 wp_insert_post 创建一个页面并将其内容设置为 Elementor 页面,并将内容设置为 Elementor 模板。我会将其传递给“post_content”参数吗?

标签: wordpresscustom-wordpress-pages

解决方案


/* you can use below code to add content when page create */
$new_page = array(
            'post_type' => 'page',
            'post_title' => 'hello',
            'post_content' => 'hello page content',
            'post_status' => 'publish',
            'post_author' => 1,
        );
$new_page_id = wp_insert_post($new_page);

推荐阅读