OK, so here’s the function that should do the trick:
function modify_events_to_use_new_field() {
$events = get_posts( array(
'post_type' => 'event',
'post_status' => 'any',
'posts_per_page' => -1
) );
foreach ( $events as $event ) {
if ( preg_match('@^(.*) - ([^-]*)$@', $event->post_title, $matches) ) {
// you'll have to modify the POST_META_KEY to the real name of your custom field
update_post_meta( $event->ID, '<POST_META_KEY>', date('Ymd', strtotime($matches[2]) ) );
}
}
}
Now you have to change the name of custom field in there and run that function.
Related Posts:
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- WordPress Orderby Numeric Value Not Working
- Show the same Article Available in Other Categories
- Post image in WordPress not appearing on home page
- Update Post Meta for a logged in user
- Two Custom Post Types Many to Many Relationship
- Update postmeta Parent when post_status child change
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Advanced custom field – posted fields from custom post type
- Get_post_custom not fetching value from array wordpress
- Add a form in every post and save data in post meta
- SELECT custom post type and its meta in SQL
- Save data is post using php front end
- How to display posts with plugin (advanced custom fields) field groups?
- WordPress – display relationship between blog posts and custom posts
- Show posts from WP Custom Post Type selected from a field in a metabox
- Adding specific custom fields (images) to post excerpt
- How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
- Linking posts together with Advanced Custom Fields “both ways”
- update a posts of other custom post type
- Edit post meta direct from post.php?
- How to create content automatically when a post is published?
- Display a post count from a custom metabox selection
- Top 30 Songs using Custom Post Type
- Styling first post using Advanced Custom Fields
- Automatically add custom taxonomy when meta value gets to a set number or beyond
- I am having a problem with fetching product data in the Gutenberg block editor
- How to automatically update ACF field value every year?
- How to check if user meta field is empty in conditional else statement
- Display only one post each WEEK
- How to set YouTube video as featured image?
- List children on child post
- How can I dynamically add a post to a custom post type which uses a custom field?
- Notice: Undefined index: error and understanding wordpress
- Problem with WordPress query on page using custom fields
- Restrict custom post type from appearing with ?post_types=
- the_content() not outputting anything (Advanced Custom Fields)
- Show custom post type filtered by category
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- create parent post using wp_insert_post
- Turn on and off custom post type from admin?
- Missing Posts in Custom Taxonomy List
- Get posts between custom dates
- Display random posts, but omit the post it is on?
- How do I do this with WordPress? Taxonomies?
- Disable block with taxonomies at post page
- How to implement a Google map store locator
- I would like to have different styles for my posts based on the content of each post
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- Showing posts from different categories and from custom post type
- Get latest 3 posts from multiple CPT in one query
- Deleting Custom Posts & Meta Data on Uninstall
- Widget: Custom Post Type Post Listing Dropdown on Admin Side
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Which post does a taxonomy term belongs to?
- List custom taxonomy specific to one custom post type
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- Meta query for custom post type ignored in main query
- Changing custom type name hides the posts
- How do I create an archive page as a including metadata?
- Display Ad on Specific Categories
- How to add a post slug to a url?
- Add custom ID to CPT posts only create not update
- Hiding posts by other users and non-logged in
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Bulk Update Custom Fields for Custom Post Types
- ACF Field on CPT Slug
- Matching Chapters to a Custom posts [closed]
- Getting meta in editor plugin, and event triggering issue
- Add custom field to Posts and sort by it
- How to duplicate entire custom post type
- Add custom post type settings to wordress default posts
- WP_Query order by custom field, then randomly order some of results
- A better way to add a meta box to custom post types
- Cluster CPT posts to users based on ACF value from their profile on dashboard
- Restrict Access to Posts based on Custom User and Post Meta Data
- ACF Values Don’t Show After Import Unless I Edit/Update Post
- Get related posts of child term of custom post type
- Problem with displaying posts in the CPT category
- get_post_meta not working on publishing
- Should wp_postmeta meta_key always be unique for a given post_id?
- Troubles with acf/save_post and WP_Query
- Query custom post type with ACF Date
- JS innerhtml changing style when using AJAX
- custom post type WYSIWG removes paragraphs when displayed
- Stuck in Order by more then one
- Custom Post Type + ACF and performance [closed]
- Show titles, date of all posts on single category page
- how can I register a post_meta field in an existing CPT and then call it again with get_post_custom()?
- get_post_meta returning no value in custom post type alert email
- Meta Query Not Returning Output Despite Having Matching Values
- Side effects of Script and Iframe in post
- post meta parameter in post custom-post-type endpoint with restapi
- ACF From & To Date Validations
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- How to change the post type a theme shows by default?