Connecting to Headless Wordpress

Hi guys. First of all I am not a dev guy. I do only a little css, js and php but I am a self-taught.
My question is: I can find only connecting frontity to a domain, but how can I connect frontity to a Headless Wordpress that is hosted on a normal server ?

In your frontity.settings.json you can connect to https://yourwebsite.com/wp-json via:

image

Further explanation can be found here: https://docs.frontity.org/getting-started/connecting-to-wordpress

If you’d like to learn more about WP REST API, please see here: https://developer.wordpress.org/rest-api/

2 Likes

exactly, but what if I only host my WordPress on a server and I don’t have a domain connected to it? Then what should I put in the URL field?
Tx.

Hi @alin, Welcome to the Frontity community. If you don’t have a domain then you could add an entry in the hosts file on your development machine mapping the IP address of the server to any made up domain. This will only work for development, you will need a domain for deploying your finished site.

I don’t know if I expressed exactly what I meant to. Basically I have a wordpress installation on remarketingo.com

I have finished my app with Frontity and connected it to remarketingo.com in settings.frontity.js

But now I would like to add that domain to the app itself.

If I do that how can i connect the WordPress installation afterwards since Will have no domain connected to it?

Hi Alin,

This is a networking issue. You need to point the domain to our instance in CloudFlare. This documentation is not for your exact use case, but may provide some insight into a similar issue:https://community.cloudflare.com/t/how-do-i-connect-heroku-app-to-my-domain-name-at-cloudflare/61848

If I understand your issue correctly. Let me know how it works out!

Hi @alin

OK, now I understand your issue. Thanks for the clarification.

We recommend that you put the WordPress site on a sub-domain, e.g. wp.remarketingo.com, update the url in frontity.settings.js to point to the new sub-domain, and then direct remarketingo.com to the Frontity installation.

To do this you will have to change either the A record or CNAME on your domain.

Hope this helps.

3 Likes

Hi @mburridge

Tx for the explanation.

Last question is, how can I prevent google from indexing both domain and subdomain but still receive metadata from yoast in WordPress installation?

Hi @alin

You can use the @frontity/head-tags package to get the Yoast head tags. The latest version of Yoast adds them to the WP REST API.

To stop search engines from indexing the WordPress site display no content there. Create a minimal theme which is just the bare bones needed, i.e. a styles.css and an index.php. The index.php file could just have a wp_die() statement.

1 Like

Hi @mburridge I answer you this late because I wanted to see if the solution you gave me works.
Unfortunately wp_die() statement for not prevent google from indexing my wordpress installation (on a subdomain).
Any other idea? I have duplicate results from both domain (frontity) and subdomain (wordpress) in the SERP

Hi @alin

That’s very strange. Surely if your WordPress site’s theme is displaying no content then there’s nothing for Google to index! :man_shrugging:

What do you see when you visit the WordPress site in your browser?