Reputation: 21
Is there a way to generate multiple new pages in wordpress with the same template, content and everything else except page name in Wordpress. The names of the new pages will be from a list of about 300 cities.
I found a plugin called BulkPress where i can insert the list and it generates the pages but with the default template and no content.
EDIT: Sorry i missed one important thing! All the pages need to be subpages of one already made parent page and the template and content needs to be copied from that parent!
Upvotes: 0
Views: 646
Reputation: 745
You could create this with programmatically. Put below code in your active template functions.php
. It will insert 300 pages.
wp_insert_post( array $postarr, bool $wp_error = false, bool $fire_after_hooks = true )
e.g.,
foreach($i=1;$i<=300;$i++){
$my_post = array(
'post_title' => wp_strip_all_tags( "Your post Title" ),
'post_type' => 'page',
'post_content' => "Post Content Goes here",
'post_status' => 'publish',
'post_author' => 1,
'page_template' => 'template-blog.php',
'post_author' => get_user_by( 'id', 1 )->user_id,
);
// Insert the post into the database
wp_insert_post( $my_post );
Upvotes: 2