Created
May 19, 2015 17:42
-
-
Save thierrypigot/39e6035bdf47fbc083f8 to your computer and use it in GitHub Desktop.
ACF : Exclude current post/page/cpt from relationship field results
This file contains hidden or 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 | |
/** | |
* Exclude current post/page/cpt from relationship field results | |
*/ | |
add_filter('acf/fields/relationship/query/name=NAME-OF-THE-FIELD', 'bcpj_query_exclude_offre_id', 10, 3); | |
function bcpj_query_exclude_offre_id( $options, $field, $the_post ) | |
{ | |
if( is_admin() ) | |
{ | |
$options['post__not_in'] = array( $the_post->ID ); | |
// $options['post_status'] = array( 'publish' ); | |
} | |
return $options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment