|
<?php |
|
// add this to your theme's functions.php or ask your developer to append the following lines |
|
add_filter( 'smart_seo_export_fields', 'child_theme_export_tags_categories', 8, 1 ); |
|
function child_theme_export_tags_categories( $fields ){ |
|
|
|
$fields[] = array( 'categories', 'child_theme_callback_categories' ); |
|
$fields[] = array( 'tags', 'child_theme_callback_tags' ); |
|
|
|
return $fields; |
|
} |
|
|
|
function child_theme_callback_categories( $post ){ |
|
if( $post->post_type == 'post' ){ |
|
return strip_tags( get_the_category_list( ', ', '', $post->ID ) ); |
|
} |
|
return ''; |
|
} |
|
|
|
function child_theme_callback_tags( $post ){ |
|
if( $post->post_type == 'post' ){ |
|
return strip_tags( get_the_tag_list( '', ', ', '', $post->ID ) ); |
|
} |
|
return ''; |
|
} |
|
|
|
// to process `categories` and `tags` columns during CSV import, make sure you grab the category and tag id |
|
add_action( 'smart_seo_import_update', 'demo_update_categories_tags', 10, 3 ); |
|
function demo_update_categories_tags($post_id, $data, $headings){ |
|
|
|
// check if `categories` column is present on CSV. Value should be integer |
|
if( isset( $data['categories'] ) && !empty($data['categories']) ){ |
|
wp_set_object_terms($post_id, $data['categories'], 'category'); |
|
} |
|
|
|
// check if `tags` column is present on CSV. Value should be integer |
|
if( isset( $data['tags'] ) && !empty($data['tags']) ){ |
|
wp_set_object_terms($post_id, $data['tags'], 'post_tag'); |
|
} |
|
|
|
} |
|
|
|
?> |