Created
January 18, 2018 08:37
-
-
Save natenault/770cf0f833fe2e590e88b1cdf9d9e2ea to your computer and use it in GitHub Desktop.
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
/** | |
* Include only published posts in post query. | |
* | |
* @param array $args | |
* @param array $field | |
* @param int $post_id | |
* @return array | |
*/ | |
function nn_query_only_published_posts( $args, $field, $post_id ) { | |
$args['post_status'] = array( 'publish' ); | |
return $args; | |
} | |
add_filter( 'acf/fields/relationship/query', 'nn_query_only_published_posts', 10, 3 ); | |
add_filter( 'acf/fields/post_object/query', 'nn_query_only_published_posts', 10, 3 ); | |
add_filter( 'acf/fields/page_link/query', 'nn_query_only_published_posts', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment