Hello.
I have a requirement to populate a datatable using js and acf. I’ve localized the script on the document with a query, and can loop through the standard postdata just fine using
localized_script_query.post.id
I can traverse this query in the console to get the id;author;title;excerpt;sourceURL just fine, but am unable to find where the ACF fields are stored so I can reference them….
Does anyone know where these fields are stored in the post object, or how I can reference them directly in the js file?
Below is the output of a queried post in my browser’s console..
{ID: 77, post_author: ‘1’, post_date: ‘2022-03-21 17:46:41’, post_date_gmt: ‘2022-03-21 17:46:41’, post_content: ‘ ‘, …}
ID: 77
comment_count: “0”
comment_status: “open”
filter: “raw”
guid: “{{url}}”
menu_order: 0
ping_status: “closed”
pinged: “”
post_author: “1”
post_content: ” ”
post_content_filtered: “”
post_date: “2022-03-21 17:46:41”
post_date_gmt: “2022-03-21 17:46:41”
post_excerpt: “”
post_mime_type: “”
post_modified: “2022-03-21 17:48:28”
post_modified_gmt: “2022-03-21 17:48:28”
post_name: “a0x6q00000qv7cfuab”
post_parent: 0
post_password: “”
post_status: “publish”
post_title: “a0X6Q00000Qv7cfUAB”
post_type: “lwp_data”
to_ping: “”
[[Prototype]]: Object
post meta is not returned when you do WP_Query(). You must loop over every post to get that information separately and somehow append that to the post information before your localize the value.
You can’t find it because it isn’t there.