| 1 |
<?php |
| 2 |
// Create a Contact us page |
| 3 |
$post = array( |
| 4 |
'comment_status' => 'closed', |
| 5 |
'ping_status' => 'closed' , |
| 6 |
'post_author' => 1, |
| 7 |
'post_date' => date('Y-m-d H:i:s'), |
| 8 |
'post_name' => 'Contact', |
| 9 |
'post_status' => 'publish' , |
| 10 |
'post_title' => 'Contact', |
| 11 |
'post_type' => 'page', |
| 12 |
'post_content' => '[contact-form-7 id="6" title="Contact form 1"]' |
| 13 |
); |
| 14 |
//insert page and save the id |
| 15 |
$newvalue = wp_insert_post( $post, false ); |
| 16 |
if ( $newvalue && ! is_wp_error( $newvalue ) ){ |
| 17 |
update_post_meta( $newvalue, '_wp_page_template', 'template/template-contact.php' ); |
| 18 |
} |
| 19 |
?> |