sorry for my bad English.
I want to create multiple pages when activating a plugin. This also works, but how do I get different content in the different pages?
if (!current_user_can('activate_plugins')) return;
$page_titles = array(
'Login',
'Dashboard'
);
foreach($page_titles as $page_title) {
$page = get_page_by_title( $page_title );
if( ! isset ( $page ) ) {
// create post object
$my_post = array(
'post_title' => $page_title,
'post_content' => '[shortcode]',
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_type' => 'page',
);
// insert the post into the database
wp_insert_post($my_post);
}
}
I would be very happy to receive help
$page_titles
with an array of arrays, e.g.$posts = [ [ 'title' => 'Login', 'content' => '[shortcode]' ], [ 'title' => 'Dashboard', ....