JSON API Custom Post Types
-
I’m trying to get custom post types to work with the Jetpack JSON module. I’ve added the following to my functions.php to whitelist my custom post type ‘portfolio’:
add_filter( ‘rest_api_allowed_post_types’, array($this, ‘allow_my_post_types’ ) );
function allow_my_post_types($allowed_post_types) {
if (! defined(‘REST_API_REQUEST’) || ! REST_API_REQUEST)
return $allowed_post_types;
$allowed_post_types[] = ‘portfolio’;
return $allowed_post_types;
}Unfortunately I’m still getting this error:
{“error”: “unknown_post_type”,”message”: “Unknown post type”}
I’m using https://public-api.wordpress.com/rest/v1/sites/www.thewirelessguy.co.uk/posts/?type=portfolio to call the JSON.Any ideas?
- The topic ‘JSON API Custom Post Types’ is closed to new replies.