Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • ffto

    (@ffto)

    Robanna, I had the same problem,

    Here’s a quick fix:
    Go to /wp-content/plugins/yet-another-related-posts-plugin/yarpp_meta_boxes_hooks.php

    at the end, uncomment the last line saying:
    // do_action(‘add_meta_boxes_settings_page_yarpp’);

    The experiments boxes will then show.

    Plugin Author ffto

    (@ffto)

    Hi thesturs,

    I’m really sorry I haven’t answered before, I haven’t checked my account in a long time, I’ll look into this this weekend.

    ffto

    (@ffto)

    Hi sireneweb,

    does the second function I posted worked? I compared your function with the WPML one “get_language_for_element” and it’s exactly the same code.

    i’ve updated the function again, to validate if the user has WPML turned off, so it degrades gracefully without errors.

    function filter_cptonomies_get_terms ( $terms, $taxonomies, $args ){
    	global $sitepress;
    	if ( !isset( $sitepress ) ) return $terms;
    
    	$post_types = get_post_types();
    	foreach ( $terms as $iTerm => $term ){
    		if ( in_array( $term->taxonomy , $post_types ) ){
    			$post		= get_posts( 'suppress_filters=1&post_per_page=1&post_type='.$term->taxonomy.'&name='.$term->slug );
    			$lang		= strtoupper( $sitepress->get_language_for_element( $post[0]->ID, "post_{$term->taxonomy}" ) );
    			$current	= strtoupper( ICL_LANGUAGE_CODE );
    
    			if ( is_admin() ){
    				$term->name = "{$term->name} ({$lang})";
    			}elseif ( $lang !== $current ) {
    				unset( $terms[$iTerm] );
    			}
    		}
    	}
    	return $terms;
    }
    add_filter( 'get_terms' , 'filter_cptonomies_get_terms' , 20 , 3 );

    Do you have an example of the bug? I’m not able to reproduce the problem.

    ffto

    (@ffto)

    here’s an updated version :

    function filter_cptonomies_get_terms ( $terms, $taxonomies, $args ){
    	global $sitepress;
    	$post_types = get_post_types();
    	foreach ( $terms as $iTerm => $term ){
    		if ( in_array( $term->taxonomy , $post_types ) ){
    			$post		= get_posts( 'post_per_page=1&post_type='.$term->taxonomy.'&name='.$term->slug );
    			$lang		= strtoupper( $sitepress->get_language_for_element($post[0]->ID, "post_{$term->taxonomy}" ) );
    			$current	= strtoupper( ICL_LANGUAGE_CODE );
    
    			if ( is_admin() ){
    				$term->name = "{$term->name} ({$lang})";
    			}elseif ( $lang !== $current ) {
    				unset( $terms[$iTerm] );
    			}
    		}
    	}
    	return $terms;
    }
    add_filter( 'get_terms' , 'filter_cptonomies_get_terms' , 20 , 3 );

    it shows the LANG when in the back end, but when in the front end, it shows only the ones in the current languages.

    Thread Starter ffto

    (@ffto)

    thank you, it works really well

    ffto

    (@ffto)

    Hi sireneweb,

    I had the same problem, so I added this code to my functions.php:

    function filter_cptonomies_get_terms ( $terms, $taxonomies, $args ){
    	global $sitepress;
    	$post_types = get_post_types();
    	foreach ( $terms as $iTerm => $term ){
    		if ( in_array( $term->taxonomy , $post_types ) ){
    			$post	= get_posts( 'post_per_page=1&post_type='.$term->taxonomy.'&name='.$term->slug );
    			$lang	= $sitepress->get_language_for_element($post[0]->ID, "post_{$term->taxonomy}" );
    			$term->name = "{$term->name} ({$lang})";
    		}
    	}
    	return $terms;
    }
    add_filter( 'get_terms' , 'filter_cptonomies_get_terms' , 20 , 3 );

    I would have preferred showing only the current language cpt-onomies, but when you change the language of the post (in the Language metabox), it reloads the Category taxonomy, but not the CPT-onomies taxonomies.

    I’m sure I could figure out what jQuery function gets triggered to reload the default taxonomy, but adding the language to the term name is good enough I think.

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