Created
September 7, 2013 16:51
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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