Skip to content

Instantly share code, notes, and snippets.

@freddielore
Last active June 5, 2019 02:37
Show Gist options
  • Save freddielore/ed3cbec6e1b5aee3b832b296c6c1f353 to your computer and use it in GitHub Desktop.
Save freddielore/ed3cbec6e1b5aee3b832b296c6c1f353 to your computer and use it in GitHub Desktop.
[export-custom-fields] Exporting Custom Fields data for bulk editing #seo
<?php
add_filter( 'smart_seo_export_fields', 'my_theme_export_other_custom_fields', 8, 1 );
function my_theme_export_other_custom_fields( $fields ){
$fields[] = 'class_type'; // class_type will exported to CSV as well
$fields[] = 'fees'; // fees will exported to CSV as well
$fields[] = 'class_description'; // class_description will exported to CSV as well
return $fields;
}
add_action( 'smart_seo_import_update', 'my_theme_update_more_custom_fields', 10, 2 );
function my_theme_update_more_custom_fields($post_id, $data){
update_post_meta( $post_id, 'class_type', sanitize_text_field( $data['class_type']) );
update_post_meta( $post_id, 'fees', sanitize_text_field( $data['fees']) );
update_post_meta( $post_id, 'class_description', sanitize_text_field( $data['class_description']) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment