Last active
June 5, 2019 02:37
-
-
Save freddielore/ed3cbec6e1b5aee3b832b296c6c1f353 to your computer and use it in GitHub Desktop.
[export-custom-fields] Exporting Custom Fields data for bulk editing #seo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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