airesvsg / acf-to-wp-rest-api Goto Github PK
View Code? Open in Web Editor NEWPuts ACF data into the WP-REST-API (WP-API)
Home Page: https://wordpress.org/plugins/acf-to-wp-rest-api
Puts ACF data into the WP-REST-API (WP-API)
Home Page: https://wordpress.org/plugins/acf-to-wp-rest-api
I'm using ACF's acf_add_options_page()
and acf_add_options_sub_page()
to create option pages and subpages, and I can't find a way of retrieving these fields on the REST API.
I've registered one page with two subpages:
add_action('init','register_option_pages');
function register_option_pages() {
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Apresentação do Projeto',
'menu_slug' => 'apresentacao',
'capability' => 'edit_posts',
'position' => 5.7,
));
acf_add_options_sub_page(array(
'page_title' => 'Sobre',
'parent_slug' => 'apresentacao',
));
acf_add_options_sub_page(array(
'page_title' => 'Estrutura',
'parent_slug' => 'apresentacao',
));
}
}
There's content on the fields, but nothing shows up on the REST API.
I noticed there's a /acf/v3/options/(?P<id>[\w\-\_]+)/?(?P<field>[\w\-\_]+)?
route described on the /acf/v3/
endpoint, so I tried the following routes, with no succes:
/acf/v3/options/
: returns 404
./acf/v3/options/apresentacao
: returns {"acf":[]}
./acf/v3/options/apresentacao/sobre
: returns {"sobre":null}
./acf/v3/options/acf-options-sobre
: returns {"acf":[]}
How should I proceed?
Hi, again.
I have several questions:
1. When i request to a post that not exist, i show in the response the field of the unique post created.
Note: The post 8 not exist in the wordpress admin
2. When i tried make the request to the fields in a page not show nothing, how i must make a request for the fields in the pages?.
3. In the request to the options, in the response show this:
The fields in ACF are configured like this:
Thanks for you help. I appreciate.
I temporary need to use v1 of the REST API and would like to change acf
to something else (say, custom_fields
). Your explanation for v2 (airesvsg/acf-to-rest-api#41) worked exactly as expected. So, I tried to do something similar in v1 using the acf_to_wp_rest_api_{$this->type}_data
filter.
But, I wasn't able to get it to work.
apply_filters( "acf_to_wp_rest_api_{$this->type}_data", $data, $object, $context );
Any guidance would be appreciated.
Is there any guide on how this can work I tried everything!
I followed the same instructions nothing seems to work for me.
I always get these errors.
1-{"code":"rest_cookie_invalid_nonce","message":"Cookie check failed","data":{"status":403}}
2-{"code":"rest_cookie_invalid_nonce","message":"\u0641\u0634\u0644 \u0627\u0644\u062a\u062d\u0642\u0651\u0642 \u0645\u0646 \u0645\u0644\u0641 \u062a\u0639\u0631\u064a\u0641 \u0627\u0644\u0627\u0631\u062a\u0628\u0627\u0637","data":{"status":403}}
Can Anyone help?
Hey! Thanks for this great plugin!
I already had a look at the other issues here, but still can't get it to work...
I want to get all the posts from the CPT "calendar" with a specific ACF-Field Value.
Would it be possible to request it like this:
".../wp-json/wp/v2/calendar/?meta_key=land&meta_value=de-AT"
Thanks in advance!
Lukas
I am using ACF and WP Rest API for the backend of a Mobile App and for some reason the ACF field isn't updated but the rest of the regular WP fields are. I don't get an error or anything, it just doesn't take my updated content. For some reason it doesn't change the default value. Im using AngularJS to make the http call but its not working. Im not running into an authorization. The call is accepted but the content isn't set.
Here is my call
$http({
method : 'PUT',
url : 'http://www.roydezign.com/demo/rtb/wp-json/wp/v2/posts/' + $scope.itemID,
data : JSON.stringify($scope.editPost), // pass in data as JSON
contentType: 'application/json',
headers : {'Authorization': ' Bearer ' + token }
})
Im narrowing it down to the link, it shows up on the REST API endpoints but not allows me to alter it. How can I get this working?
Will this eventually let us be able to post data to acf through the wp api?
Hello,
Thanks for the plugin, I've got great use out of it.
However, I'm stuck with one particular issue, which I cannot find a resolution to anywhere, hopefully you can help.
I have a custom post type 'projects' & an ACF field 'client'.
I want to make a JSON call which will return my projects ordered by client alphabetically.
I have am trying the following URL: "/wp-json/wp/v2/projects?meta_key=client&filter[orderby]=meta_value_num"
I imagine there is some code that will ned to go into my functions.php file, but I cannot find what it will need to be. I appreciate your help.
Many thanks,
Jack.
Is there a way to include ACF fields from a custom post type ?
Hey there,
First off, thanks for creating this plugin. I think it will save me some time with custom post data.
From what I can tell, I can only request ACF data for a single post, given the ID, but not a group of posts. When I query my custom post type, I don't see any ACF data on the returned posts:
e.g. /wp-json/wp/v2/projects
.
Right now, the only way to get everything is to request my projects
and then fire off a single request for each project's ID to get its ACF data using /wp-json/acf/post/<ID>
.
It'd be really great to have ACF data being appended to post / custom post responses with the key acf
and all its data within. Am I missing something?
Thanks!
Hello
Thanks for this great plugin.
I'm having trouble retrieving the acf fields in my cpt response.
Currently im making this call:
GET http://website.com/wp-json/v2/locals/
the "acf" field is not displaying.
This is what I added in my functions.php
add_action( 'init', 'my_custom_post_type_rest_support', 25 );
function my_custom_post_type_rest_support() {
global $wp_post_types;
$post_type_name = 'locals';
if( isset( $wp_post_types[ $post_type_name ] ) ) {
$wp_post_types[$post_type_name]->show_in_rest = true;
$wp_post_types[$post_type_name]->rest_base = $post_type_name;
$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
}
}
"acf" field is showing up only in posts but not in my CPT, any suggestion?
Hi @airesvsg
:) I try to use ACF filter[orderby]=netflix_id for sort posts, but seems can't work.
Do I make something wrong?
http://projects.noeinoi.com/awwrated/wp/wp-json/acf/v3/posts?order=asc&filter[orderby]=netflix_id
HI folk!
thanks for making this great plugin!
i have a question about showing [attachment] custom field data in the gallery field in post by wp-json.
The custom field [media_docu_scource]& [media_docu_description]I made in Attachment could not be shown in the ACF gallery field, which i made the gallery field in post.
Please see the attached image below
Do you know any method for solving this problem ?
thanks a lot!
Hey guys, thanks for the awesome plugin, it works perfect! :)
I was just wondering if there are any plans to implement a shortcode support? Sometimes when I get fields contents the shortcodes come as they are in the database and not as compiled parts.
Many thanks once again!
I am blocked on an API integration. I am trying to be able to get a specific custom post by searching for a custom field.
I am trying:
Is something like this possible?
If not, is it possible to GET all custom posts, but return only a certain field?
When i make a request to the endpoints, all return null. For example:
$.ajax('http://localhost:3000/wp-json/acf/post/1').then( function( data ) {
console.log( data );
})
in the console, return null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.