Hi,
I am trying build a Gatsby site by fetching data from WordPress.
ACF data seems to not be pulled.
I have a self hosted WordPress, I have set the "useACF: true" option .
If I understand correctly, I should now have access to "childWordpressAcfField" from GraphQL.
However I do not see it appearing in the GraphQL UI, and trying to query for it returns the error "Cannot query field "childWordpressAcfField" on type "wordpress__POST"
Any idea?
Look at the using-wordpress site in the examples directory. Using
"childWordpressAcfField" doesn't always work and that form isn't
necessarily recommended. Also if you haven't, learn to explore your sites
schema in graphiql.
On Sun, Oct 8, 2017, 12:39 PM Alex Muraro notifications@github.com wrote:
Hi,
I am trying build a Gatsby site by fetching data from WordPress.
ACF data seems to not be pulled.I have a self hosted WordPress, I have set the "useACF: true" option .
If I understand correctly, I should now have access to
"childWordpressAcfField" from GraphQL.However I do not see it appearing in the GraphQL UI, and trying to query
for it returns the error "Cannot query field "childWordpressAcfField" on
type "wordpress__POST"Any idea?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/2394, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVhyejdtUEq_aa_8Uu9qAThNlNF-edks5sqPrNgaJpZM4Pxw9s
.
Hi, thanks for your answer.
I have been exploring the schema in graphiql quite a bit, and my problem is exactly that I don't see anything ACF related.
if I do:
wordpressPost {
acf
}
I get an error, "Cannot query field "acf" on type "wordpress__POST".
If I explore using ctrl+enter, nothing related to ACF pops up.
ACF is active on the site, and everything is up to date.
I'm running out of ideas LOL :)
Try installing the using-wordpress example site and poking around there.
Ok, I've tried the demo and it's got the acf fields as expected.
Then I tried to replace your WP site with mine in the gatsby-config (and also wiped all the templates of course). Then run gatsby develop, and graphiql is missing the acf fields! Argh!
Do you know which versions of WP and ACF you have on the site?
Thanks again
Do you have the acf-to-rest-api plugin installed on your site?
Hi Emil,
Yes I do, it's version 2.2.1 (latest).
I'm actually using it already on my current (PHP) website.
So weird!
@akmur I am having similar issues with ACF and the wordpress-source plugin in general, do you have a repo for this project yet? Thinking of looking into it, which versions of ACF and Wordpress are you using as well?
In addition, I found that upgrading to the latest version of the wordpress-source forces you to use the acf{...} for the GraphQL schema but means it will not return anything unless you strictly go down to the level of say:
acf{
my_repeater{
title
image
url
}
}
Let me know if any of that helps 😃
Just to join in here I cannot get ACF query to work on allWordpressPage just says "Cannot query field \"acf\" on type \"wordpress__PAGE\".", in graphiql. It used to work fine using childWordpressAcfField but that doesn't work at all in the latest version of wordpress source plugin. The docs still say to use that which is very misleading if this has been removed. I have tried working out how to use it from viewing the using wordpress example but I cannot see how to use it from this - maybe I am just stupid!
This is the query I tried (have also tried different variations):
allWordpressPage {
edges {
node {
id
title
content
excerpt
slug
status
author {
id
name
}
featured_media
menu_order
acf {
about {
services
}
}
}
}
}
Any help appreciated.
I think I will setup a test wordpress website and will let you know, I will push the code to github too
I had similiar problem. Do you guys use ACF as a plugin or do you include it in your theme functions.php ? It seems that including it in functions.php doesnt play well with acf-to-rest-api plugin (so its not related to gatsby-source-wordpress at all). If that's your setup then in functions.php manually init acf-to-rest-api plugin after including ACF:
include_once( get_stylesheet_directory() . '/acf/acf.php' );
ACF_To_REST_API::init();
Also first step would be inspecting wordpress api response (f.e
No, I use it as a plugin - and in my case the api response does have the custom fields, as I'm already using them through JavaScript
Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!
Most helpful comment
I had similiar problem. Do you guys use ACF as a plugin or do you include it in your theme functions.php ? It seems that including it in functions.php doesnt play well with acf-to-rest-api plugin (so its not related to gatsby-source-wordpress at all). If that's your setup then in functions.php manually init acf-to-rest-api plugin after including ACF:
Also first step would be inspecting wordpress api response (f.e/wp-json/wp/v2/posts) and see if results have acf field