Skip to content

Instantly share code, notes, and snippets.

@espiat
Created October 8, 2018 08:18
Show Gist options
  • Save espiat/1d81d2b6c41419bb131f380d42e660dd to your computer and use it in GitHub Desktop.
Save espiat/1d81d2b6c41419bb131f380d42e660dd to your computer and use it in GitHub Desktop.
Caldera Forms (autopopulate ) & ACF (Field/ Meta)
function filter_caldera_forms_autopopulate_post_type_args( $args, $field ) {
if( 'fld_3126036' === $field[ 'ID' ] ){ // your field ID !!!!
$args[ 'meta_query' ] =
array(
array(
'key' => 'status', // ACF field name
'value' => 'sold', // ACF field value
'compare' => '!=', // in this case every post is NOT sold
)
);
}
return $args;
};
// add the filter
add_filter( 'caldera_forms_autopopulate_post_type_args', 'filter_caldera_forms_autopopulate_post_type_args', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment