Local Community

How can I query from subdirectory?

Hi,

I’m just starting to learn WordPress and development, sorry if it is a silly question. I’ve been trying to find a clear solution for my need for a while, but I couldn’t find one so far.

Let’s say I have 2 WordPress installations:

  • Domain: a content website with a lot of blog posts, media, etc.
  • Subdirectory: a marketplace with Woocommerce, other CPTs, payment transactions, user logins, etc.

Now, I need to be able to sync both WordPress installations to query products, CPTs and show them in the root domain.

What is the best way to do it? So far, the only solution I got is that it needs to be done via REST API… is it correct?

Also, do I really need to separate both installations or is it safe to keep everything in the root domain?

Thanks a lot in advance

Welcome to the forums @karinaglf!

Given the two sites, you’re right in thinking that the only way for them to communicate is via some sort of API. The REST API is probably the most common, but you could consider installing and using the WPGraphQL plugin.

Either of those options does mean more complexity and more dev time. If you’re just starting out, it might be too much and too overwhelming, but on the other hand, if you get through it, you’ll definitely have some sweet skills to brag about!

The easiest thing in terms of development would be to consolidate the two sites and so that Woocommerce and the related products are part of the main domain. This would give you a lot of flexibility in terms of including those pieces of product content across any WP page.

I suppose the main considerations if you do decided to combine the sites:

  • Is this an established product/site? Do you need to consider SEO when merging the sites?
  • Is there a lot of traffic that’s taxing on the Woocommerce site? Unless you’ve got a good caching plan in place, that extra traffic might affect the main site.

Anyway, no wrong answer, just more of a strategy question of how you are wanting to use WP as part of the online presence!

Sorry for the late reply! Thank you so much for your response, actually this whole time I was wrapping my mind around this topic and learning a lot from tutorials. I’m very enthusiastic about WPGraphQL, it is exactly what I need.

Thanks again,
Karina

1 Like