1

I want to create a page using wp_insert_post but set the page to have Elementor content. Here is the code I have:

// Create post object
$my_post = array(
    'post_title'    => wp_strip_all_tags( 'Test Page' ),
    'post_content'  => 'elementor json goes here',
    'post_status'   => 'publish',
    'post_author'   => 1,
    'post_type'     => 'page'
  );
   
  // Insert the post into the database
  wp_insert_post( $my_post );

But when I do this, the content just prints the actual JSON.

JayDev95
  • 777
  • 2
  • 5
  • 18
  • This might get you close... https://stackoverflow.com/questions/63898766/wordpress-programmatically-insert-elementor-widgets-in-a-page – kenchilada Mar 11 '21 at 18:08

1 Answers1

0

I would create an Elementor template then export it. You then have different options. You can manually import the templates exported into the new website, or set up One Click Demo Import. Popular themes use this plugin to import ready-made templates that used Elementor.

Here is more information about both: https://powerpackelements.com/how-to-save-import-and-export-templates-in-elementor/ https://wordpress.org/plugins/one-click-demo-import/

JayDev95
  • 777
  • 2
  • 5
  • 18