It depends on what type of data your array contains. But you would need to first loop your array; and create a valid string for passing into the post_content argument.
For example, if your array consisted of text strings:
$newArray = array( 'test_1', 'test_2', 'test_3' );
$text="";
// Loop the array and create a text string
foreach( $newArray as $string ) {
$text .= $string . ' | ';
}
Now you can insert the text into the post content.
$new_post = array(
'post_type'=>'post',
'post_title'=>"New post created Programmatically",
'post_content'=> $text
);
wp_insert_post($new_post);
Related Posts:
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Custom Post Type Plugin: Where Do I Put The Template?
- Creating a Custom Post Type as a Plugin? Why?
- How to add a button to custom post type’s posts-page
- Is flush_rewrite_rules necessary when creating a custom post type? Why?
- Unable to filter on field on edit.php page
- WP Query group/order by category name
- Save or update data when custom post published
- Custom Taxonomy and tax_query Issue?
- Using posts and postmeta table to store custom Address Book Plugin data
- template_redirect not working, apparently for no reason
- Custom role capabilities to administrator not taking effect (no plugin)
- How to add multiple featured image in meta box in post editor?
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- How to append element after thumbnail
- handling csv data with a custom post type
- Custom Post Type | Fatal Error on register_post_type()
- Set object terms not working on plugin activation
- Using custom page templates with plugin [duplicate]
- Custom Post Type rewrite
- Admin notice not displaying
- Detect where custom post type is declared
- Insert Multiple Post with Same Publish Button
- get_object_taxonomies() returns empty array for custom post type
- custom post type not showing in menu
- Adding a custom post type taxonomy template in plugin
- Plugin: register custom post types, child ready and performance best practices
- Add custom ID to CPT posts only create not update
- Add custom post type as submenu [closed]
- Getting meta in editor plugin, and event triggering issue
- Unable to get Custom Plugin Options data
- Form action/link to render a plugin in WordPress front-end
- What is the best practice for displaying my plugin content in themes?
- How to use TinyMCE Editor for one of my custom post meta field?
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Deleting taxonomy terms and relationships on a custom post_type when a user is deleted
- custom comments form for custom post type
- Problems wp_insert_post and save_posts filter
- Custom fields for custom post type
- wordpress remove views from action links in a custom post
- When should I create custom post types?
- Custom post type’s extra fields – how to handle?
- Save Multiple Metabox values
- Send a conditional email notification when a custom field value changes in Post Type
- Getting 400 Bad Request on AJAX Call
- Main query not querying any posts in custom taxonomy template
- Show current custom taxonomy
- How to insert data into meta box from another plugin?
- How exclude or skip post type with get_next_post_link
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- Add post type pages with plugin
- Create a select metabox that the user can pupolate?
- How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop
- Most viewed post of custom post type
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Mandatory field in Custom post
- Custom post type page with parameter
- Custom post type category link redirecting to 404 page
- Translate website without duplicate custom post
- How to store the third party script with HTML code in the wordpress custom input field?
- How to show the post which checkbox is not selected
- Replace Content of Sidebar on Custom Post Type
- How to upload an image to a custom post type
- How to stop the custom post type URL from the google search?
- Changing CPT permalink
- I have a random letter appearing before my content. Where to start looking for the cause?
- Apply a custom Template to a Custom Post Type from within a plugin
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- Error when moving custom post type to bin
- Admin metabox with custom post type dropdown option not update choosed input after saving
- Correct way to register custom post type from external php file?
- How to Use A Custom Post Type as Taxonomy for Another Custom Post Type
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- php output of generated custom metabox
- Not Able to List CPT Based on Taxonomy Term
- How to reset HTML filter input fields on CPT list page?
- Can’t save custom post type fields
- Simple renaming my custom post type set with a plugin doesn’t work?
- get_post_types doesn’t work in plugin
- Show Templates in Custom Post Type Editor
- Associate custom categories to different user IDs
- Shortcode error
- Render custom taxonomy query as single template
- How to avoid hardcoded text in a custom page template?
- How to use get_sidebar in plugin folder?
- Get term_id for each instance of custom taxonomy
- How to internationalize the sub menu name “categories” in Custom post type?
- Creating a Custom Post Type as a Plugin? Why?
- How to create an upload page (front side)
- WordPress Roles
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- Custom Post Type urls not working
- get_post_types() is returning null
- I want to show a list of posts under specified categories
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs
- How to consume external API from WordPress post editor and display the response data in the custom field?
- Redirect to All Custom post types
- Redirection after saving a post
- How to fix post_tags not showing for a CPT in new post for a custom user role?