Skip to content

Instantly share code, notes, and snippets.

@eduwass
Created September 18, 2015 13:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduwass/a0a6fe746cd603636ed6 to your computer and use it in GitHub Desktop.
Save eduwass/a0a6fe746cd603636ed6 to your computer and use it in GitHub Desktop.
ACF Post Object field and WPML (show posts of both languages => disabling filtering)
<?php
/* Customize the ACF Post Object queries, so they return posts in both languages */
function customize_acf_query( $args, $field, $post )
{
if($field['type']=='post_object'){
$args['orderby'] = 'title';
$args['suppress_filters'] = true; // Suppress filters so WPML doesn't filter to only 1 lang
return $args;
}
}
// add filter function
add_filter('acf/fields/post_object/query', 'customize_acf_query', 10, 3);
@Frique
Copy link

Frique commented Feb 21, 2017

Since the filter only applies to the post_object field, checking the $field['type'] is redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment