Could you add this to the theme please?
Hi,
After wasting seconds/minutes creating a thank you page and adding content, I thought this might be better automated and included in the theme itself.
This is for the thank you page a user will see after sending a message via the contact form.
Again I'm not sure if it's coded the best way as I have been taking samples from the net to do this.
Just add this to the child theme functions.php file.
//thank you page automatic creation
if ( ! is_admin() ) {
$new_page_title = 'Thank You';
$new_page_slug = 'thank-you2';
$new_page_content = '<h2><span class="red">Thank you for your email enquiry.</span></h2>
<h2>We will get back to you shortly.</h2><p class="small">If you don\'t hear back from us within 48 hrs, please check your spam box.</p><span><a href="javascript
:history.back()">← Go Back</a></span>';
$new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template.
//don't change the code bellow, unless you know what you're doing
$page_check = get_page_by_title($new_page_title);
$new_page = array(
'post_type' => 'page',
'post_title' => $new_page_title,
'post_name' => $new_page_slug,
'post_content' => $new_page_content,
'post_status' => 'publish',
'post_author' => 1,
);
if(!isset($page_check->ID)){
$new_page_id = wp_insert_post($new_page);
if(!empty($new_page_template)){
update_post_meta($new_page_id, '_wp_page_template', $new_page_template);
}
}
}
Happy Christmas