Created
August 18, 2019 06:07
-
-
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
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 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