ACF not showing in API

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #45712

    Hello Team!
    Hope you are doing great!

    I have been busting my ass for hours and I can’t get the ACF to be visible in API.
    For example:

    This is a search that fetches the podcast (CPT) with the name “Revolution”. I have enabled the Index Table, and also added the CPT, that I want to be visible in the results, through the option inside plugin settings (printscreen:

    But when I check on the API link, I won’t get any of the CPT (like feed_url, related, etc) here:

    Any ideas to get the ACF values inside the API in each search?

    *I have created and updated the table, cleared the cache, and checked from incognito.

    Thanks again for your time!
    Kind Regards,

    Ernest Marcinko
    Ernest Marcinko

    Hi Tom,

    I’m afraid that will not work that way. Selecting the fields to earch for will not get the field values. There might be a way to do it via custom code, but I am not sure:

    add_filter( 'asp_results', 'asp_custom_meta_to_wpjson', 10, 4 );
    function asp_custom_meta_to_wpjson( $results, $search_id, $is_ajax, $args ) {
        if ( $args['is_wp_json'] ) {
    		foreach ($results as $k=>&$r) {
    			if ( isset($r->post_type) && $r->post_type == $post_type ) {
    				// Declare the fields explicitly
    				$r->my_field1 = get_field('my_field1', $r->id);
    				$r->my_field2 = get_field('my_field2', $r->id);
        return $results;

    After this they should be popping up in the the $post->asp_data->my_field1 fields and so on..

    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.