Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Created May 19, 2015 17:42
Show Gist options
  • Save thierrypigot/39e6035bdf47fbc083f8 to your computer and use it in GitHub Desktop.
Save thierrypigot/39e6035bdf47fbc083f8 to your computer and use it in GitHub Desktop.
ACF : Exclude current post/page/cpt from relationship field results
<?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