Skip to content

Instantly share code, notes, and snippets.

@cagriuckan
Last active June 26, 2021 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cagriuckan/02313dc5d4cb39b69f612dc70a421279 to your computer and use it in GitHub Desktop.
Save cagriuckan/02313dc5d4cb39b69f612dc70a421279 to your computer and use it in GitHub Desktop.
wordpress automatic page creation
add_action('after_setup_theme', 'uckan_create_pages');
function uckan_create_pages(){
$awesome_page_id = get_option("awesome_page_id");
if (!$awesome_page_id) {
$post1 = array(
'post_title' => "Sayfa Adınız!",
'post_content' => "",
'post_status' => "publish",
'post_type' => 'page',
);
$postID = wp_insert_post($post1, $error);
update_post_meta($postID, "_wp_page_template", "template-giris.php");
update_option("awesome_page_id", $postID);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment