Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Created September 7, 2013 16:51
Show Gist options
  • Save fdaciuk/6477180 to your computer and use it in GitHub Desktop.
Save fdaciuk/6477180 to your computer and use it in GitHub Desktop.
Criar páginas no WordPress sem utilizar o painel com wp_insert_post
<?php
$default_configs = array(
'post_status' => 'publish',
'post_type' => 'page',
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_content' => ''
);
$panel_pages = array(
array(
'post_title' => 'Página 1',
'post_name' => 'pagina1'
),
array(
'post_title' => 'Página 2',
'post_name' => 'pagina2'
),
array(
'post_title' => 'Página 3',
'post_name' => 'pagina3'
)
);
foreach( $panel_pages as $p_page ) {
if( !get_page_by_path( $p_page['post_name'] ) ) {
wp_insert_post( array_merge( $default_configs, $p_page ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment