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 to put my code: plugin or functions.php?
- Should I use custom post types or a custom database tables for plugin development?
- Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?
- Using add_theme_support inside a plugin
- The Great Plugin Nomenclature Contest of 2011
- How to completely disable a taxonomy archive on the frontend?
- How do you create an archive for a custom post type from a plugin?
- How to set a fall back template for a custom post type in a plugin?
- How to add multiple images to custom post type?
- Redirect after deleting post and keep track of pagination
- get_edit_post_link() not working as expected when passed id in plugin
- How do I Make a custom post type get a custom post template in a plugin
- WordPress metabox file upload in custom post [duplicate]
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- WordPress custom post action hook
- Multiple Permalinks for custom post type post
- On clicking on the category name the page is redirecting on 404 pge
- Uploaded image not appearing in custom post type
- Row actions not showing? Why?
- How to: add option to add more checkboxes on custom post type
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to add notification in the sidebar of the administration panel when a Custom post type is created? [duplicate]
- how to set default value for checkbox in wordpress
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- How to have the right design for a custom post type without accessing themes
- Dynamic Custom Post Type Plugin
- Customize permalink when creating a post
- Custom Taxonomy Not Showing in Menu
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- Get all of user’s custom post types in WP Admin for plugin
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Custom Post Type: Upload Multiple Images
- WordPress theme custom capabilities not works
- Getting template_include to work when allow_url_include is off?
- WordPress post_where & posts_join not working only for custom post type
- Orderby CPT custom fields not working
- Use custom metabox to update automatically a post after a given date
- Custom Permalink to remove category word , keeping posts permalink with date?
- Adding a metabox on a CPT’s submenu page
- Plugin fatal error
- Suggestion on custom post type/ taxonomy relationship
- ACF in wordpress
- Theme independent plugin by using default page template
- How do you make a list and list item relation if custom post types?
- Add form after woocommerce admin order edit
- Unable to format dates to put in event calendar
- How to Use Custom Meta Field Instead of CPT Title in Post URL
- Dynamic assign a custom template to custom post type posts
- Custom post type in Custom widget – $listItem
- Validate Custom Post Type fields
- Is it possible to sort metabox teaxtarea values?
- Generating and downloading files with WP API
- Convert Custom Table Data Based Plugin To Be Searchable
- Modify a plugin function output from another plugin
- Custom rewrite rules for /pastissues/%category%-%postname%.html
- Content in WP Editor displayed below CPT shortcode [duplicate]
- Writing a custom Glossary plugin
- Limit Amount of Pages users can create in Custom Post Types
- restricting custom rewrite to just one custom post type
- Wp Meta Query does not work while simple Query Works
- Change Text in Admin Panel
- How to show Custom Post Types under Taxonomy in a new WordPress page template?
- Custom Endpoint For Specific Custom Post Type
- How to add a default predefined thumbnail when creating a brand new post?
- Plugin Development using classes – Public & Private Callbacks
- Create a post automatically if search result has zero results
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to display the post using a shortcode in WordPress?
- Custom post type specific item design
- Correct way adding External classes to Custom Post type and output their methods to template
- Issue removing columns from admin table
- Shortcode and get_template_part
- dynamic vue widget inside custom post
- Custom Post Type Front Page Gives 404
- Getting data from dynamically allocated metaboxes within a custom post
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- WP REST API Custom endpoint don’t work in my plugin
- how to allow subscriber to add/edit/delete custom post type
- Facing some Issues on Two Parts Custom Post Type Taxonomy Names
- Custom meta box in editor of custom post type not working
- what file is required to be created in plugin folder in order to show all the post content of a CPT with the help of permalink
- Not Able to Get Custom Post Type in Single and Single-custom-post-type
- Remove Custom Capability
- Can I override the permalink/slug on creation
- call_user_func_array() error after moving to another server
- Displaying multiple custom post types in single post type at admin section
- Custom Post Type Audio Content
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Items By Group added to custom post type
- Custom Taxonomy Showing in WP Menu
- Issue on Adding Taxonomy to Custom Post Type Using Function
- Custom Post Types in plugins?
- Multiple Block Quotes without using HTML
- How to apply order on custom taxonomy and custom meta key on custom post type
- Hide custom post type and use its slug in new plugin menu
- Don’t display post if post has empty body
- Set a Custom Post Type as a Homepage
- Need some hints for my own WP theme development
- How to separate posts by categories?
- Make term slugs of custom taxonomy available in WP REST API for custom post type?