Skip to content

Instantly share code, notes, and snippets.

@freddielore
Created July 9, 2020 02:36
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 freddielore/698b61d63c2931e4cce13025974fb3ce to your computer and use it in GitHub Desktop.
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
<?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