• Resolved joopleberry

    (@joopleberry)


    Hi,

    I’m trying to use the ElasticPress API to search and hiding certain fields from the returned results.

    I managed to use the following code to hide certain fields from WP’s REST API results but they don’t seem to work with ElasticPress API (elasticpress/v1/pointer_search/)

    function my_rest_prepare_project( $data, $post, $request ) {
        $_data = $data->data;
        
        $params = $request->get_params();
        if ( ! isset( $params['id'] ) ) {
        	unset( $_data['content'] );
        	unset( $_data['post_content'] );
    
        }
       $data->data = $_data;
        
        return $data;
        }
    add_filter( 'rest_prepare_project', 'my_rest_prepare_project', 10, 3 );
    • This topic was modified 3 years, 4 months ago by joopleberry.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Hiding custom fields from elasticpress API requests result’ is closed to new replies.