Quantcast
Channel: Question and Answer » wpdb
Viewing all articles
Browse latest Browse all 44

wpdb and acf via wp rest api

$
0
0

I made a custom endpoint with wp rest api for

/wp-json/dn/locations

which in turn runs the following wpdb query

$sql = "SELECT * 
FROM wp_posts p
WHERE p.post_type = 'location'
AND p.ID = 133;";
$results = $wpdb->get_results($sql);

Which returns fine but unfortunately my ACF fields aren’t showing up in there. There are quite a few in the several queries I’m doing and this is going to turn into a mess quickly if I have to chase every field by hand. Is there an easier way to get posts with all the ACF fields attached?


Viewing all articles
Browse latest Browse all 44

Trending Articles