Title: [Plugin: Flexible Recent Posts] Basic support for polylang
Last modified: August 20, 2016

---

# [Plugin: Flexible Recent Posts] Basic support for polylang

 *  Resolved [QuickeneR](https://wordpress.org/support/users/quickener/)
 * (@quickener)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-flexible-recent-posts-basic-support-for-polylang/)
 * Polylang is one of the plugins that add to a WordPress blog the multilingual 
   capability. Have translations of posts, pages, etc. Unfortunately, FRP does not
   filter posts by language and thus can show post excerpts in a different language
   than the rest of the blog.
    Here is a patch that allows to select languages by
   typing their slugs.
 *     ```
       --- templates/recent-posts-form.php.org2	2012-07-25 14:04:31.000000000 +0600
       +++ templates/recent-posts-form.php	2012-10-09 15:10:49.000000000 +0600
       @@ -47,6 +47,15 @@
        	<label
        		for="<?php print $this->get_field_id( 'all_posts_link_footer' ); ?>"><?php print __( 'Show after all posts', 'frp' ); ?></label>
        </p>
       +<p>
       +	<label for="<?php print $this->get_field_id( 'language_filter' ); ?>"><?php print __( 'Filter posts by language(s)' ); ?>:</label>
       +	<img src="<?php print $plugin_dir . 'images/help.png'; ?>"
       +		 title="<?php _e( 'Filter posts by language. Use the form \'en\' or \'en,ru\' for multiple languages. The list of valid languages is in Settings - Languages. Requires Polylang plugin', 'frp' ); ?>"
       +		 class="frp-form-help" alt="<?php _e( 'Help', 'frp' ); ?>">
       +	<input class="widefat" id="<?php print $this->get_field_id( 'language_filter' ); ?>"
       +		   name="<?php print $this->get_field_name( 'language_filter' ); ?>"
       +		   value="<?php print $instance['language_filter']; ?>" type="text">
       +</p>
        <h4 class="frp-form-group-title"><?php print __( 'Categories' ); ?><img
        	src="<?php print $plugin_dir . 'images/help.png'; ?>" title="<?php _e( 'Posts categories', 'frp' ); ?>"
        	class="frp-form-help" alt="<?php _e( 'Help', 'frp' ); ?>"></h4>
   
       --- class-recent-posts-widget.php.org2	2012-07-25 14:00:57.000000000 +0600
       +++ class-recent-posts-widget.php	2012-10-09 15:09:25.000000000 +0600
       @@ -38,7 +38,8 @@
        				'template'                  => '',
        				'theme'				=> 'default',
        				'all_categories'            => true,
       -				'categories'                => array()
       +				'categories'                => array(),
       +				'language_filter'           => ''
        			)
        		);
   
       @@ -71,12 +72,16 @@
        		$instance['all_posts_title'] = htmlspecialchars( $instance['all_posts_title'] );
   
        		if ( !empty( $instance['categories'] ) || $instance['all_categories'] ) {
       -			$posts = get_posts(
       -				array(
       -					'numberposts' => $instance['number'],
       -					'category'    => implode( ',', $instance['categories'] ),
       -				)
       +			$posts_query = 	array(
       +				'numberposts' => $instance['number'],
       +				'category'    => implode( ',', $instance['categories'] ),
        			);
       +			# Only add the language filter if Polylang is installed
       +			if ( function_exists('pll_the_languages') ) {
       +			    $posts_query['lang'] = $instance['language_filter'];
       +			}
       +
       +			$posts = get_posts($posts_query);
   
        			if ( !empty( $posts ) ) {
        				$category_link = ( empty( $instance['all_posts_link'] ) ) ? get_category_link( end( $instance['categories'] ) ) : $instance['all_posts_link'];
       @@ -103,6 +108,7 @@
        		$instance['all_posts_link_title'] = isset( $new_instance['all_posts_link_title'] ) ? true : false;
        		$instance['all_posts_link_footer'] = isset( $new_instance['all_posts_link_footer'] ) ? true : false;
        		$instance['all_posts_title'] = strip_tags( $new_instance['all_posts_title'] );
       +		$instance['language_filter'] = strip_tags( $new_instance['language_filter'] );
        		$instance['all_posts_link'] = '';
       ```
   
 * [http://wordpress.org/extend/plugins/flexible-recent-posts/](http://wordpress.org/extend/plugins/flexible-recent-posts/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Paul Annekov](https://wordpress.org/support/users/thesteelrat/)
 * (@thesteelrat)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-flexible-recent-posts-basic-support-for-polylang/#post-3103282)
 * [qTranslate](http://wordpress.org/extend/plugins/qtranslate/) plugin must work
   perfectly without any plugins :).
    I will add filters to FRP, so you can create
   yor own plugin, that will add integration with **Polylang**. I think, that hardcoding
   usage of other plugins is not good. There are more plugins for multilingual blog
   and I can’t hardcode integration with each of them. So it’s another plugin’s 
   job.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Flexible Recent Posts] Basic support for polylang’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/flexible-recent-posts_d3c4a5.svg)
 * [Flexible Recent Posts](https://wordpress.org/plugins/flexible-recent-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/flexible-recent-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/flexible-recent-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/flexible-recent-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/flexible-recent-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/flexible-recent-posts/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Paul Annekov](https://wordpress.org/support/users/thesteelrat/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-flexible-recent-posts-basic-support-for-polylang/#post-3103282)
 * Status: resolved