Skip to content

Instantly share code, notes, and snippets.

@freddielore
Created August 18, 2019 06:07
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/8d6419a1beac65adfac8c3967bebb045 to your computer and use it in GitHub Desktop.
Save freddielore/8d6419a1beac65adfac8c3967bebb045 to your computer and use it in GitHub Desktop.
[smart_seo_export_fields] smart_seo_export_fields filter with added callback #wordpress #wp #seo #php
<?php
// add this to your theme's functions.php or ask your developer to append the following lines
add_filter( 'smart_seo_export_fields', 'demo_export_other_custom_fields', 8, 1 );
function demo_export_other_custom_fields( $fields ){
// See if this is a WPML site and add columns "language_code", "parent_title" to CSV
if( class_exists( 'SitePress' ) ){
$fields[] = array( 'language_code', 'callback_language_code' );
$fields[] = array( 'parent_title', 'callback_parent_lang' );
}
return $fields;
}
function callback_language_code( $post ){
$post_language_details = apply_filters( 'wpml_post_language_details', NULL, $post->ID ) ;
return $post_language_details['language_code'];
}
function callback_parent_lang( $post ){
return get_the_title( apply_filters( 'wpml_object_id', $post->ID, $post->post_type ) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment