I see. Thanks for that explanation. But how so that in frontity.settings.js, where you connect to WP REST API, you don’t include “/v2/” (i.e., http://localhost/schools/wp/wp-json)? (Sorry for unrelated questions.)
Secondly, what do you mean exactly with “Ensure that the cookielawinfo CPT has some content in the WordPress admin pages”?
Frontity handles the endpoints after the wp-json part. In fact, in recent versions of Frontity, you only need to put your domain name. Recent versions use state.source.url rather than state.source.api. If you’re using a version of Frontity that has state.source.api then you need to define both your domain and the wp-json suffix. See here for more details.
I mean that there should be some posts that are of the type cookielawinfo.
Do you have the GDPR Cookie Consent plugin installed in WordPress? That plugin provides the cookielawinfo CPT. However it doesn’t add the CPT to the REST API, which is what the code snippet you included above does - it adds the cookielawinfo CPT to the WordPress REST API.
Yes, I have it installed. And yes, I also understand that this code, I included above, needs to be added as well, and it is added. But the GDPR still doesn’t show up in Frontity theme. It only shows up in WordPress.
I still don’t get what you mean with “posts” in this cookielawinfo CPT, though. Do you mean if I have added any custom posts except the ones that are already included in this GDPR Cookie Consent plugin (like shown in the picture below?).
That’s an endpoint to fetch the data from, it’s not a path that you would use with Frontity - Frontity uses the endpoint internally to get the data into the state so that you can work with it. To navigate a Frontity site you would use the same permalinks that WordPress uses.
Regarding the posts, where is the content for the plugin if it’s not in posts?
So the shortcode adds, or should be adding, the cookie info to the page content? If that’s the case then you don’t need the code you cited when you started this thread in your functions.php file. That code is only needed if you need to add a CPT to the REST API.
So now we need to figure out why the cookie info isn’t in the page content that is being sent to Frontity.
OK, so I installed the plugin and did some digging around.
It turns out that the content for the cookie consent plugin is buried away in the WordPress wp_options table. It is in an option called CookieLawInfo-0.9 and it looks like all the info and settings for the plugin are contained within that option, including the text content. I’ve included screenshots (taken from Sequel Pro) below and have highlighted both the option and also the text content corresponding to the text in the Message field under the Customise Cookie Bar tab.
You will need to write some PHP code, either in the theme’s functions.php file or in a custom plugin, that retrieves that option and gets the content you want. You will then need to create a custom endpoint, again in PHP, exposing that content in the REST API, and then fetch it from Frontity and handle it.
TBH, unless you need to use WordPress to content manage this it might be simpler to just add a React component to your Frontity theme to display a consent bar.