If you want to add custom page layouts as part of a child theme (like in my Free Divi child themes), then you will need to add some code to the functions.php file of your child theme. Doing this will mean that when someone uploads your child theme and activates page builder on a new page, the page layouts you add will show in the “load layout” section (right at the bottom of the list)

Step 1 – Get the layout code. To get the layout code from your page builder you will need to 1st create your page as normal using page builder. Because there is no code view in pagebuilder, you will need to then switch to a non Divi theme, such as twentyfifteen, so you can then go to your page, select edit page and then copy everything out of code view window.

Step 2 – Add code into functions.php. Add this code into the code below @ ***** your layout from step 1 here *****
each page layout must have a different name, as you see below page 1/2/3…

<?php function myprefix_add_layout() {
$dc_layouts = array();

$dc_layouts[] = array(
‘title’ => ‘NAME-OF-YOUR-LAYOUT’,
‘content’ => <<<EOT

EOT
);

$dc_layouts[] = array(
‘title’ => ”NAME-OF-YOUR-LAYOUT-2′,
‘content’ => <<<EOT

EOT
);

$dc_layouts[] = array(
‘title’ => ‘NAME-OF-YOUR-LAYOUT-3’,
‘content’ => <<<EOT

EOT
);

foreach ( $dc_layouts as $dc_layout ) {
$title = sanitize_text_field( $dc_layout[
‘title’] );

if ( ! get_page_by_title( $title, ‘OBJECT’, ‘et_pb_layout’ ) ) {

$add_layout = array(
‘post_title’ => $title,
‘post_content’ => $dc_layout[‘content’],
‘post_status’ => ‘publish’,
‘post_type’ => ‘et_pb_layout’,
);

$layout_id = wp_insert_post( $add_layout );

add_post_meta( $layout_id, ‘_et_pb_predefined_layout’, ‘on’ );
}
}

}
add_action( ‘load-post.php’, ‘myprefix_add_layout’ );
?>

Pin It on Pinterest