WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Poly language combined with ACF (1 post)

  1. kab2512
    Member
    Posted 2 months ago #

    I would like to know if it is possible to get the language
    from polylang within filtering query below?

    Currently I have hardcoded $args['lang'] = 'da';
    But i need to get the language code dynamically so when i change language in wp admin-mode the list will change acordingly to the choosen language.

    function acf_relationship_query( $args, $field, $post ) {
    
    	 $meta_query = array( array(
    			 'key'     => '_start_date',
    			 'value'   => time(),
    			 'compare' => '>'
    	 ));
    
        $args['post_type']  = 'events';
        $args['meta_query'] = $meta_query;
        $args['tax_query']  = $tax_query;
    	$args['post__not_in'] = array( $post->ID );
    	$args['order_by'] = 'meta_value_num';
    	$args['lang'] = 'da';
    	$args['order'] = 'ASC';
    
    	return $args;
    
    }
    
    add_filter('acf/fields/relationship/query/key=field_52e7d0357f1c8', 'acf_relationship_query', 10, 3);

    https://wordpress.org/plugins/advanced-custom-fields/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags