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
- Advanced search form with filters for custom taxonomies and custom fields
- Restrict custom post type to only site administrator role
- How to force one column layout on custom post type edit page?
- WordPress REST Create Post of Custom Type
- Rest Api v2 orderby meta_key in custom post type
- bulk Update post_meta with default values
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Slug for standard post post_type
- How do I create an archive page for standard posts?
- WordPress custom post type archive with description
- Remove parent from custom post type
- How can I get_post_meta() in the most efficient way?
- List all images from a single post meta value
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- How to add post_type=value when editing that post type in the WordPress admin?
- Open Custom Post Type as PDF
- Validate custom fields before save using WordPress Rest API
- how to delete all users and posts based on ‘user_meta’?
- Meta Key Value in current-user-only loop
- How to implement a Google map store locator
- custom post type WYSIWG removes paragraphs when displayed
- get_post_meta returning no value in custom post type alert email
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Get the category from custom post type
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Prioritize posts in query by meta keys?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Order post by date with ACF
- If Post Meta Equals Current Title Conditional Advanced Custom Fields
- Querying & displaying custom post type into an existent page [closed]
- Is it a good idea to add a column to the posts table?
- delete_post_meta() for whole CPT / multiple posts?
- Creating separate feeds for custom post types
- wordpress lists similar type of posts in a custom post type
- display posts of custom post type with custom taxonomy
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- Post Query not working
- meta query not retrieving posts
- creating files for displaying different custom post type posts with paging
- is it possible in a custom post, create custom fields as well whitin?
- custom taxonomy listing returns no posts
- Display author box on just certain category posts?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Am I mixing up the concept of posts pages and categories?
- If/Else child list for Custom Post Type single template within loop?
- How to achieve a multi-taxomony layout with posts?
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Show custom post type event if current day using ACF
- Filter posts by their related field’s custom field
- If ACF Post Object post has custom taxonomy term…
- WordPress retrieving $post based on random key in $_POST
- How to get post by meta value
- How do I get all authors posts of a custom post type outside loop
- minimize wp_query call to database
- Post display in separate page [duplicate]
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- Delete Post by User
- custom search results – order results differently by post type
- Only show current category post
- WordPress Contents Migration
- Problem to get the link of the default ‘post’ post type like the orther custom types
- get_post_meta for Custom Post Type ( CPT )
- Getting wrong ID
- How to make post page unique and show it on home page?
- Query Posts From Multiple Post Types
- WP Build-In Post selector for CPT
- Random meta field from specific custom post type
- How to hide home title on pages and posts?
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- How to make a non-public post on wordpress approval?
- Filter page ID outside the loop and order