Skip to content

Commit 4fb95e3

Browse files
committed
add and document filter for CPT endpoints
1 parent e1e660f commit 4fb95e3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,19 @@ It returns a JSON response with the following (returns an empty array if no post
267267
- Tags
268268
- Tag IDs
269269
- ACF fields, if applicable
270+
271+
## Hooks and Filters
272+
273+
### Filter the Custom Post Types endpoints
274+
275+
```php
276+
add_filter('better_rest_endpoints_cpt_collection', function($cpt_collection){
277+
$cpt_collection = array_flip($cpt_collection);
278+
unset($cpt_collection['oembed_cache']);
279+
unset($cpt_collection['_pods_template']);
280+
unset($cpt_collection['_pods_pod']);
281+
unset($cpt_collection['_pods_field']);
282+
$cpt_collection = array_values( array_flip($cpt_collection) );
283+
return $cpt_collection;
284+
});
285+
```

includes/get_cpts.php

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ function bre_get_cpts() {
2929
}
3030
}
3131

32+
$bre_cpts = apply_filters( 'better_rest_endpoints_cpt_collection', $bre_cpts );
33+
3234
// check if array is empty, returns array if data exists, return false if empty
3335
if( !empty($bre_cpts) ){
3436
return $bre_cpts;

0 commit comments

Comments
 (0)