Unset Custom Post Type fields
-
I can currently unset unneeded fields for posts no problem, but how can I also unset fields from custom post types?
The example below is what I’m using to unset fields for posts. Can this be altered to unset fields from a custom post type?
function qod_remove_extra_data( $data, $post, $context ) { // We only want to modify the 'view' context, for reading posts if ( $context !== 'view' || is_wp_error( $data ) ) { return $data; } // Here, we unset any data we don't want to see on the front end: unset( $data['author'] ); unset( $data['status'] ); //etc etc return $data; } add_filter( 'json_prepare_post', 'qod_remove_extra_data', 12, 3 );
- The topic ‘Unset Custom Post Type fields’ is closed to new replies.