Created
September 18, 2015 13:54
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since the filter only applies to the post_object field, checking the
$field['type']
is redundant.