Extraordinary
-
Exactly what I was looking for ! Works great with the latest version of WordPress (5.3)
No need for shortcode! To obtain a featured image that loads automatically according to the language of the plugin qtranslate-x, you can add in the file functions.php:
add_filter( 'kdmfi_featured_images', function( $featured_images ) { $args = array( 'id' => 'featured-image-en', 'desc' => 'English version of the feature image.', 'label_name' => 'English featured image', 'label_set' => 'Set english featured image', 'label_remove' => 'Remove english featured image', 'label_use' => 'Set english featured image', 'post_type' => array( 'page', 'post', 'portfolio', 'app' ), ); $featured_images[] = $args; return $featured_images; }); add_filter( 'get_post_metadata', 'wdm_change_featured_image', 10, 4 ); function wdm_change_featured_image( $feature_image_id = null, $post_id, $meta_key, $single ) { if ( $meta_key == '_thumbnail_id' ) { if(function_exists('qtranxf_getLanguage')) { if (qtranxf_getLanguage() == 'en' && kdmfi_has_featured_image( 'featured-image-en', $post_id )) { $feature_image_id = kdmfi_get_featured_image_id( 'featured-image-en', $post_id ); } } } return $feature_image_id; }
The topic ‘Extraordinary’ is closed to new replies.