Skip to content

Instantly share code, notes, and snippets.

@freddielore
Created January 20, 2020 13:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save freddielore/d4e4d6d0fcc73944c762c2747f605da1 to your computer and use it in GitHub Desktop.
[Smart SEO Export Facebook Open Graph] Using smart_seo_export_fields filter to export Facebook Open Graph meta data
<?php
/** Export OpenGraph meta data */
add_filter( 'smart_seo_export_fields', 'smartseo_export_opengraph_metas', 8, 1 );
function smartseo_export_opengraph_metas( $fields ){
$fields[] = '_yoast_wpseo_opengraph-title';
$fields[] = '_yoast_wpseo_opengraph-description';
return $fields;
}
/** Include OpenGraph meta data in bulk csv update */
add_action( 'smart_seo_import_update', 'smartseo_update_more_custom_fields', 10, 2 );
function smartseo_update_more_custom_fields($post_id, $data){
update_post_meta( $post_id, '_yoast_wpseo_opengraph-title', sanitize_text_field( $data['_yoast_wpseo_opengraph-title']) );
update_post_meta( $post_id, '_yoast_wpseo_opengraph-description', sanitize_text_field( $data['_yoast_wpseo_opengraph-description']) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment