Git Product home page Git Product logo

acf-to-wp-rest-api's People

Contributors

airesvsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

acf-to-wp-rest-api's Issues

Retrieving ACFs from custom Option Pages

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?

Request to page

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.

http://prntscr.com/9iezns

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:

http://prntscr.com/9if1y3

The fields in ACF are configured like this:

http://prntscr.com/9if2lw

Thanks for you help. I appreciate.

Rename from 'acf' in response

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.

Full Guide on Posting and Getting ACF data

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?

Filter by ACF Field Value

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

Field Not Updating

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?

Orderby ACF field

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.

Getting ACF data for a set of posts?

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!

ACF not showing in Custom Post type

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?

Questions about Attachment acf data in Gallery Field

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
how-to-insert-galleryfield

Do you know any method for solving this problem ?

thanks a lot!

Shortcodes

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!

Getting post/object by field

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:

  • /wp-json/acf/v3/book?isbn=9780143110439
  • /wp-json/acf/v3/book/isbn/9780143110439
  • /wp-json/wp/v2/book?filter[isbn]=9780143110439
  • /wp-json/wp/v2/book?isbn=9780143110439

Is something like this possible?

If not, is it possible to GET all custom posts, but return only a certain field?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.