Related Posts for multiple Custom Post Types
-
If we want to use related posts with our own custom post types, we can use this function:
function allow_my_post_types($allowed_post_types) { $allowed_post_types[] = 'your-post-type'; return $allowed_post_types; } add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types' );
But what if I want to add multiple CPTs? I′ve tried adding them line by line but that didn′t seem to work.
function allow_my_post_types($allowed_post_types) { $allowed_post_types[] = 'your-post-type'; $allowed_post_types[] = 'another-post-type'; $allowed_post_types[] = 'a-third-post-type'; return $allowed_post_types; } add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types' );
Not sure if that′s the right approach or if I can pass all post types as an array or something.
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Related Posts for multiple Custom Post Types’ is closed to new replies.