Created
June 24, 2026 04:24
-
-
Save plugin-republic/d7f02d39772d1e7a43e4af2cf8a86cb0 to your computer and use it in GitHub Desktop.
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 specific products from a Product Categories field type | |
| * Edit the $excluded_ids array below with the product IDs you want | |
| * to hide. If you need different exclusions per field, check $args['category'] to | |
| * identify the field and apply exclusions conditionally. | |
| */ | |
| add_filter( 'pewc_get_products_for_cats_args', function( $args ) { | |
| // IDs of products to exclude from all Product Categories fields. | |
| $excluded_ids = array( 123, 456 ); | |
| if ( ! empty( $args['exclude'] ) ) { | |
| $args['exclude'] = array_merge( $args['exclude'], $excluded_ids ); | |
| } else { | |
| $args['exclude'] = $excluded_ids; | |
| } | |
| return $args; | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment