Support

Account

Home Forums ACF PRO Is there a way to retrieve the fields from a particular post by postID?

Helping

Is there a way to retrieve the fields from a particular post by postID?

  • 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.

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

You must be logged in to reply to this topic.