Created
September 21, 2017 20:21
-
-
Save Shelob9/b1c5bc8ad9fcd207d8d56063967f7822 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
<?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; | |
}); |
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
<?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