Contents
How do I get posts from API?
To use the WordPress REST API, simply add /wp-json/wp/v2/posts to the end of your WordPress site URL. This will give you a list of posts (in JSON format). The default number of posts returned is 10, but you can choose to show more or less with the per_page argument — we’ll talk about that below.
How do I find my ACF key?
The “real” answer: go to the Field Group admin page, click the “display field key” button in help dropdown, then copy & paste the key into code. However, this only works for fields registered with PHP via register_field_group().
What’s the ACF key in the REST API?
This appends a key called “acf” to the rest api output for all public post types. Will be easier to customise too if you only want certain fields to be exposed. you can use filter, see below how to use. Thanks! I was looking at that, and then when I updated the WP REST API to Version 2.0-beta9, it broke your plugin.
How to add ACF field to / POST endpoint?
* Register a Rest Api field to add the related posts Acf field to the /post endpoint. * Hook: after_setup_theme. The first step is to register the field with the Rest Api. For this task we create a new function called register_related_posts_api_field. Within this function we use the register_rest_field function to register the field.
How to query posts in ACF for custom fields?
The WP_Query object is used to query posts and will return an object containing an array of $post objects and many useful methods. The get_posts function makes use of the above WP_Query object, however, it only returns an array of $post objects making it a simpler way to find and loop over posts.
Where to find ACF relationship fields in WordPress?
In my POSTS page (regular post type), I have setup a ACF relationship field. Inside this I can select company name which are all under the post type of directory_listings.