Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created September 21, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/b1c5bc8ad9fcd207d8d56063967f7822 to your computer and use it in GitHub Desktop.
Save Shelob9/b1c5bc8ad9fcd207d8d56063967f7822 to your computer and use it in GitHub Desktop.
<?php
/**
* Limit Caldera Forms post type select to EXCLUDE a category.
*/
add_filter( 'caldera_forms_autopopulate_post_type_args', function( $args, $field ) {
//IMPORTANT change this to match your field's ID
if( 'fld1234567' !== $field[ 'ID' ] ){
//CHANGE ids (or slugs) of category(s) to exclude
$args[ 'category__not_in' ] = array( '42' );
}
return $args;
});
<?php
/**
* Limit Caldera Forms post type select to specific categories.
*/
add_filter( 'caldera_forms_autopopulate_post_type_args', function( $args, $field ) {
//IMPORTANT change this to match your field's ID
if( 'fld1234567' !== $field[ 'ID' ] ){
//CHANGE ids (or slugs) of categories to include
$args[ 'cat' ] = array( '2,6,17,38' );
}
return $args;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment