wpml_jetpack_widget_get_top_posts

Filter the Top Posts and Pages by language.

Description

wpml_jetpack_widget_get_top_posts( $posts, $post_ids, (number) $count ); 

Parameters (3)

0. $posts
The posts.
1. $post_ids
The post ids.
2. $count (number)
The count.

Usage

  1. if ( !function_exists( 'wpml_jetpack_widget_get_top_posts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/3rd-party/wpml.php'; 
  3.  
  4. // The posts. 
  5. $posts = null; 
  6.  
  7. // The post ids. 
  8. $post_ids = null; 
  9.  
  10. // The count. 
  11. $count = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wpml_jetpack_widget_get_top_posts($posts, $post_ids, $count); 
  15.  

Defined (1)

The function is defined in the following location(s).

/3rd-party/wpml.php  
  1. function wpml_jetpack_widget_get_top_posts( $posts, $post_ids, $count ) { 
  2. global $sitepress; 
  3.  
  4. foreach ( $posts as $k => $post ) { 
  5. $lang_information = wpml_get_language_information( $post['post_id'] ); 
  6. $post_language = substr( $lang_information['locale'], 0, 2 ); 
  7. if ( $post_language !== $sitepress->get_current_language() ) { 
  8. unset( $posts[ $k ] ); 
  9.  
  10. return $posts;