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

  1. kab2512
    Posted 2 years 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);


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic