Created
July 9, 2020 02:36
-
-
Save freddielore/698b61d63c2931e4cce13025974fb3ce to your computer and use it in GitHub Desktop.
[Export Term Meta Data] Exports term meta data to CSV for bulk editing #smartseo #wordpress
This file contains hidden or 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', 'theme_export_tax_custom_fields', 8, 1 ); | |
function theme_export_tax_custom_fields( $fields ){ | |
$fields[] = 'custom_field_name_1'; | |
$fields[] = 'custom_field_name_2'; | |
return $fields; | |
} | |
add_action( 'smart_seo_import_update', 'theme_update_more_tax_custom_fields', 10, 2 ); | |
function theme_update_more_tax_custom_fields($term_id, $data){ | |
if( isset( $data['taxonomy_type'] ) ){ // making sure we're dealing with taxonomy | |
update_term_meta( $data['taxonomy_id'], 'custom_field_name_1', sanitize_text_field( $data['custom_field_name_1'] ) ); | |
update_term_meta( $data['taxonomy_id'], 'custom_field_name_2', sanitize_text_field( $data['custom_field_name_2'] ) ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment