Closed rizkysyazuli closed 5 years ago
Hi, please do ask here :) This is helpful information to anyone using ember-wordpress.
To query by ACF fields you'll need to explicitly allow it in your Wordpress theme's functions.php
AND use the default endpoint wp-json/wp/v2
and not the ACF one.
Here's an example that will allow you to query a custom post type by a my_field
field.
add_filter('rest_{type}_query', function( $args ) {
$args['meta_query'] = array(
array(
'key' => 'my_field',
'value' => esc_sql( $_GET['my_field'] ),
)
);
return $args;
});
Remember to replace
{type}
with the name of your custom post type andmy_field
with the name of your field..
Then you can filter like this: https://example.com/wp-json/wp/v2/artists?my_field=some-value
.
See https://github.com/airesvsg/acf-to-rest-api/issues/13#issuecomment-189403357. I just tested it and got it working. Let me know if it works for you, too. Would be nice to get this into the readme as well.
First of all, sorry if i'm asking this in the wrong repo.
So i've configured the adapter to use custom endpoints provided by ACF to REST API plugin.
But what i get in return is only the ACF metadata. Where's the rest of the WP post data??
NOTE: I want to query posts based on ACF fields. If you guys have other ideas, i'm all open.