If you need to do this conversion in PHP, as part of whatever import process, then you can just convert the comma-separated values into an array with explode()
, and then use update_post_meta()
, which will automatically serialise the value for you:
$value="Morning,Daytime";
$array = explode( ',', $value );
update_post_meta( $post_id, 'hours_of_operation', $array );
Use trim()
if your comma separated values include, or could include, spaces:
$value="Morning, Daytime";
$array = explode( ',', $value );
$array = array_map( 'trim', $array );
update_post_meta( $post_id, 'hours_of_operation', $array );
If, for whatever reason, you need to serialise the value yuorself in PHP, you can use serialize()
to convert the array to a serialised string.
$value="Morning,Daytime";
$array = explode( ',', $value );
$serialized = serialize( $array );
Related Posts:
- Importing old blog with regular posts into new custom post types
- Resource Issues: Importing external data into custom post type and keeping records up to date
- Custom post types not imported properly
- WordPress import not importing custom taxonomy
- Beginner question: Accessing functions.php through admin web interface in order to import custom post types?
- WP All Import – Using Xpath to set a select value
- WordPress export tool doesn’t export post-format value of custom post type?
- Create a clone from one WordPress site to another in a few minutes
- ACF Values Don’t Show After Import Unless I Edit/Update Post
- How to handle a CSV with 65,000+ rows and make it searchable?
- How to import files to individual posts of a custom type
- Create a page by importing data from an XML file ( On clicking a button inside admin options page)
- Two-way synchronizing of a post type among multisite blogs
- Invalid content when I try to import custom post type from the old template wordpress
- Custom post types imported from another wordpress site, not showing on frontend unless I go in and reupdate them
- Exporting Post type from one theme and importing it to another theme
- Importing URLs of Audio Enclosures
- Imported Content Doesnt Show Up On Frontend
- Creating connections programmatically with common fields on CPT’s
- Multiple orderby values in WP_Query
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Permalinks for CPT breaks permalinks to pages
- WordPress custom post type url change
- Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox
- Get the Category Name instead of ID from WP-API
- Used with meta_query in query_posts works slowly
- image srcset returns false
- How to specify a Parent post type for a Child post type?
- Search by category displaying wrong items
- Permalinks for custom post-types within custom taxonomies not found
- Custom post type archive page not working
- How can I force custom post type to use a specific template?
- Change post featured image on hover
- How to get all `supports` attributes by post type?
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- List of Posts in a Custom Field
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- Create template for taxonomy results limited by Custom Post Type
- URLs for child terms
- changing meta value and meta key of price field
- Trash / Draft a WordPress custom post after custom date field expires
- Posting to a Custom Post Type from front end – user generated content
- WPMU: Cross site custom post type
- Filter custom post types by a field value
- custom post type and non-standard gallery
- Output terms for custom post types
- Replace dynamically content in a custom database table when a custom post is created
- Custom Permalinks for Custom Post Types
- New post from database
- The loop does not show users
- Custom Post taxonomy template
- Getting the list of the latests posts and custom type posts in the homepage
- Placing Admin Post Metaboxes in Tabs
- How can I make reusable post types with complex custom field structures?
- Right way to store a large set of similar information on website? [duplicate]
- Custom post type single page 404
- Custom Post Type Archive Page URL
- Custom Post Type canonical link / pagination redirecting to root
- Custom post type – Errors
- Extracting Post ID and passing through as an attribute in a shortcode
- WP_Query doesn’t accept Category ID
- Error in WP Query. If variable is empty it is displaying previous post value
- Why isn’t my custom post type using the corresponding custom post template?
- Get author image for posts in loop on custom type posts page
- Change Taxonomy Permalinks
- using post_type with meta_query
- Display Custom Taxonomy of custom post type
- WP Query Post Type with same Taxonomy name
- categories of custom post type shows in CMS but not in the frontend webpage
- make playlist from a custom post type
- How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes
- Get all post from custom post type in custom taxonomy
- How to add custom permalink struct with DYNAMIC author to a Custom Post Type
- WPNavi pagination links not working on custom pages
- Rewrite Rule for custom post type link with or without taxonomy terms
- How to add to taxonomies to a post type
- Custom plugin contact form connecting to mailchimp API
- Posts structure named to blog, how to add month and year
- How to change post cpt with submit button?
- Filtering custom post types using category taxonomy
- Storing every individual update to the posts being updated over time?
- Rewrite nested urls for custom post type
- Custom Post Type featured option
- Change post structure
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Custom post type Premalinks main page and details page
- Two custom post type relations
- Update Custom Field daily within 7days
- set_post_thumbnail or media_sideload_image adds image multiple times in media library
- How to use wp_set_object_terms depending on page ID?
- Change CPT Edit Target Link for Admin List
- How can I produce multiple webpages with a different output based on one entry/Page/custom Page?
- custom taxonomy not return in the code
- Rewrite rule taxonomy url with different values in one function
- How to display posts from IMPress for IDX Broker on home page? [closed]
- Permalinks for Custom Post Types and Taxonomies
- Group search results by post type, but having a unique heading for each section?
- selecting custom post types and taxonomies for hub page listing blocks
- Remote database access on another wordpress site’s custom post type
- How do I get parameters from the URL?