You just add the content to your initial array. The most simple way is using the titles as array indices like this:
$pages = [
'Login' => 'Some content',
'Dashboard' => 'Some other content'
];
foreach ( $pages as $title => $content )
{
if ( get_page_by_title( $title ) ) {
continue; // skip this page
}
wp_insert_post([
'post_title' => $title,
'post_content' => $content,
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_type' => 'page',
]);
}
Related Posts:
- How to redirect to settings page once the plugin is activated?
- Get page content using slug
- How to output message during plugin activation
- Change the_title() of a page dynamically
- Prevent network activation of plugin
- Inserting Taxonomy Terms During a Plugin Activation?
- How to edit the properties of a page programmatically?
- Using wp_cron with custom time interval and the register activation hook
- Call activation hook multiple times
- Pages 404 in wordpress
- How to create a dynamic page based on form data with a plugin?
- Use an empty page to build custom plugin output
- Is it possible for a plugin to register a page template file?
- Only allow plugin to be activated on root site of multisite
- Dropdown list of pages to get page id to store in plugin options
- Calling a function from functions.php in custom page/ blog post
- why creating tables using $wpdb is not being executed while installing plugins?
- How do I approach removing menu items on the fly based on settings in my plugin?
- Override pluggable functions in a plugin?
- Set a specific page as 404 – not found via my own plugin
- Plugin activation error due to unexpected output
- Is there a faster way than wp_insert_post to add content to a blog
- Create a Page via plugin
- Settings not set after calling register_setting()
- Use wp_set_post_terms() instead of wp_insert_post()
- update post meta for checkbox in the admin when inserted in the front-end
- Set page template programaticlly in plugin
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Secure Pages Best Practice
- Plugin generated virtual pages
- Add Link Category on Activation?
- WordPress Plugin Activate / Deactive Failing
- Add Password Generator on password protected page
- Remove all removed pages from wordpress
- ECHO Executing 4 Times In Head
- WordPress pages are not published due to External database connection with WPDB class
- Create page (not the post type) dynamically
- How to get custom post_author?
- Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘Blocks\Base\Activation’ not found
- How to list all images used on a specific page?
- Create fixed static pages
- Plugin can’t be activated [closed]
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Activate / Deactivate plugin
- Plugin to create Posts and Forums then choose category and parent forum
- Set page to draft on plugin deactivation
- Creating posts with links from a txt file
- How to create archive page to add in menu
- Load specific page when a custom URL is hit
- Using wp_mail to send email?
- How to show comments from different Plugins to same post type?
- How to check if `comment_meta` exists before inserting the comment?
- How to get the `comment_post_ID`?
- Posts form with AJAX request – Plugin development
- Custom plugin foreach wp_insert_post not working
- Plugin frontend page design irrespective of the theme used
- Sanitize WordPress Array Input?
- Custom non-template page on front end fails to render
- How to prevent wp_insert_post from creating a new post every second?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Custom Plugin activation error in Multisite
- How to store in the database directly the translation?
- Unable to show a message after plugin activation
- Choose default template for a page with code
- Getting duplicate page when activating my plugin
- How do I control the list of Pages an author can see?
- How to add conent (text) to Add New pages form of admin in WordPress
- auto create only 1 wp page in activate custom plugin
- Refresh or redirect page after activate my plugin
- I can install my plugin in localhost but not in my server
- WordPress plugin tables become corrupt
- Add Page With Parent ID
- Yet another wp_insert_post infinite loop. What is wrong?
- Create pages for authors
- Deactivate plugin on registration
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- how can a plugin return an error message on activation?
- Using a Page Template Not in Theme
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- My activator class isn’t running the code inside
- Generating Multiple Divi Pages from Database
- Problem with Owl Carousel, infinite loop [closed]
- How to sync with plugins update after I have done manual optimizations?
- How to retrieve a value via get_option when the option_value is stored in a multi-dimensional array?
- Add Admin Menu Inside Construct or Init
- How to create thumbnail of different files?
- Admin-ajax.php appending a status code to ajax response
- comment_email hook doesn’t seem to work for comment editor field
- Subscribe to author?
- How to use output buffering in WordPress hooked functions?
- What happens when two or more plugins use the same hook?
- Adding columns to core tables
- Custom Stylesheet instead of Inline CSS for WordPress Customizer API Overrides
- Update product prices from remote file
- product-attribute-slug-is-too-long-28-characters-max
- What is the source of the $post_id in a hook argument?
- Use content filter on the post that is password-protected
- foreach argument to get specific file types getting too many returns
- Installing plugins on installation/activation
- Loading jQuery library from WordPress admin