• Resolved tdebaillon

    (@tdebaillon)


    I use the plugin as a widget in my sidebar, and have put the following code in my functions.php file, in order to filter the posts displayed according to the language chosen

    add_filter( 'gtc_atts_filter', 'gtc_language_filter' );
    function gtc_language_filter( $atts ) {
    	if ( !$atts )
    		return false;
    	if (ICL_LANGUAGE_CODE == 'en') {
    		$my_filter_cat = '3';
    	} else {
    		$my_filter_cat = '92';
    	}
    	$atts['catlimit'] = $my_filter_cat;
    	return $atts;
    }

    This code doesn’t work anymore. As I am a bit lousy about updates, I couldn’t say if this began to happen after updating WP (3.8 used) or the plugin (1.4.8).

    Thanks in advance for your help.

    http://ww.wp.xz.cn/plugins/google-analytics-top-posts-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Justin Sternberg

    (@jtsternberg)

    Just tested with:

    add_filter( 'gtc_atts_filter', 'gtc_language_filter' );
    function gtc_language_filter( $atts ) {
      if ( !$atts )
        return false;
    
      $atts['catlimit'] = '24';
      return $atts;
    }

    and it is working as expected. Only thing I can say is maybe remove the return false section in case you don’t have any other attributes.

    Thread Starter tdebaillon

    (@tdebaillon)

    Thanks for your answer.
    As the filter code works as expected, I guess the problem lies elsewhere, typically in WPML, which maintains ICL_LANGUAGE_CODE in its API.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem using filters’ is closed to new replies.