Help with urls where wordpress is in a subdirectory of the domain

I’m having a little confusion around using a wp site that is stored in a sub folder of the domain:

What settings do I need to have the frontity site work as http://localhost:3000/ without the sub folder name in the urls?

eg. http://mydomain.com/thewordpresssite

in frontity.settings.js I’d have my source object as:

 {
  "name": "@frontity/wp-source",
  "state": {
    "source": {
      "url": "http://mydomain.com/thewordpresssite",
      "homepage": "landing-page",
      "postsPage": "blog"
    }
  }
}

The slug of my homepage set under wp-admin/options-reading.php is: “landing-page”

For the most part the routing works by using http://localhost:3000/thewordpresssite/page-slug or http://localhost:3000/thewordpresssite/blog - (although the posts page is not set in wp settings) for the posts archive…
But with the homepage I’m getting 404 errors…I’ve tried a few options such as “/thewordpresssite/landing-page/” and some variations.

Instead of setting the subdirectory in the url, try setting the subdirectory value.

See: @frontity/wp-source - API Reference

Hi @llylebennett

If your WordPress installation is in a sub-directory of the domain, that’s only a concern to WordPress.

In the WordPress Settings page you have options to set the WordPress Address and the Site Address.

If you’re installation is in a sub-directory then the two values will be different, otherwise they will normally be the same.

Frontity is only interested in the REST API. WordPress will deliver the content from the domain defined in the Site Address setting. Frontity doesn’t know about the sub-directory, nor does it need to know about it.

Frontity will use the same URLs that appear in the address bar when you navigate the normal WordPress site. So, for example, you would use http://localhost:3000/blog to access the blog page.

The state.source.url setting should normally be the same as is defined in the Site Address setting.

You can test what the endpoint of the WordPress REST API is by entering http://yourdomain.com/wp-json/wp/v2 in the address bar of your browser, or in a tool like Postman. If you get content back then whatever you have used in place of http://yourdomain.com is what should be in state.source.url.

Hope this helps.

Thanks @Johan and @mburridge
I got it working :slight_smile:

1 Like

@llylebennett can you show your wp-source settings please to help others

Thanks