Skip to content

Instantly share code, notes, and snippets.

@jbrinley
Created April 9, 2014 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbrinley/10293288 to your computer and use it in GitHub Desktop.
Save jbrinley/10293288 to your computer and use it in GitHub Desktop.
<?php
function tribe_filter_import_data_before( $post ) {
if ( $post['post_type'] == TribeEvents::POSTTYPE && !empty($post['post_parent']) ) {
$start_date = '';
if ( isset($post['postmeta']) && is_array($post['postmeta']) ) {
foreach ( $post['postmeta'] as $meta ) {
if ( $meta['key'] == '_EventStartDate' ) {
$start_date = $meta['value'];
break;
}
}
}
if ( !empty($start_date) ) {
$post['post_title'] .= '[tribe_start_date]'.$start_date.'[/tribe_start_date]';
}
}
return $post;
}
add_filter( 'wp_import_post_data_raw', 'tribe_filter_import_data_before', 10, 1 );
function tribe_filter_import_data_after( $post ) {
if ( $post['post_type'] == TribeEvents::POSTTYPE ) {
$post['post_title'] = preg_replace('#\[tribe_start_date\].*?\[\/tribe_start_date\]#', '', $post['post_title']);
}
return $post;
}
add_filter( 'wp_import_post_data_processed', 'tribe_filter_import_data_after', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment