I have a custom post type called publication. On a page, I query some of these publications using WP_QUERY
. I also use Chartjs to draw graphs based on the data from the fields in each publication. What I want to do is to get the fields using JavaScript API but I’m not sure how. If the api allowed us to get fields by post ID, that would solve the issue. However, it is required that the fields have to be on the current page. Any advice/help is appreciated. Many thanks in advance!
The ACF JS API is really only useful in the admin on the current edit page. There is not functionality in it to query posts of get values from other posts.
You would need to write your own AJAX queries to get values from other posts, or you would need to output those values on the front end to “localize” your script or otherwise include the values you need in javascript output for the page.