Can part of my WordPress website be headless?

Just to set the scene I have a client that has a wordpress site with a mixture of "static" pages and woocommerce shop. The product catalogue has approx "86,000" products in it. This number may include variation though it is massive. The client relies heavily on product filtering functionality for users to get to the correct products. Using WP AJAX to do this has proven really slow. After a bit of research I think the best way to perform the …
Category: Web

WordPress REST API not working on localhost

I have a WordPress site running WordPress 5.9.3 that is using a React-based theme, which uses the REST API (v1), to retrieve content and menus from the standard WordPress CMS back-end. However, when trying to install it locally, I can't get the API to work and retrieve the needed data. I'm using a Docker environment based off this repo: https://github.com/kassambara/wordpress-docker-compose Since the theme uses React and the REST API to get the site content, trying to view the site gets …
Category: Web

Wordpress as a CMS - best way to decouple publishing/front-end

For various reasons, this is important, but I am unsure if their are better ways OR other ramifications: CMS = Wordpress as a CMS. WebSite = Static site generator. Currently when a post publishes on CMS I used API to send the info to WebSite which generates the page. All works. However, I don't want the CMS to ALSO publish post. I current handle this by redirecting all traffic to CMS to /wp-admin/ page. This seems not ideal. I would …
Category: Web

Woo commerce product setup - custom product types?

Appreciate any advice on setting up products in Woocommerce - I have 6 types of products where each one has very unique product categories so I am wondering if I should create custom product types for each one or should I just use the simple product type and have a custom field where I select the unique product type? Also, for custom fields is ACF recommended s we Irgun Woocommerce? Thanks in advance.
Category: Web

Only expose routes with prefix /wp-json on WordPress using Apache

Pretty straightforward: I want to only expose routes with the /wp-json prefix so that I can use headless WordPress without exposing the rest of my WordPress site to the internet. I'm running this on Apache, but haven't yet figured out the proper syntax for .htaccess. So far I have tried: <Directory /> AllowOverride None </Directory> <Directory /wp-json*> AllowOverride All </Directory> <Directory /wp-json*/*> AllowOverride None </Directory> and <Directory "/wp-json/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow …
Category: Web

Add image to each podcast series (or category) in headless WordPress instance

We have a WordPress instance that we query through it's API. Contents are posts, or episodes from a Podlove plug-in. We have four podcasts, though at the moment only one is set up in Podlove. We indicate the podcast an episode belongs to by adding a category. Now we'd like to add a logo to each podcast series. We are considering two solutions: We could set up all podcasts in Podlove (which probably should have been done from the beginning). …
Category: Web

How to get WP GraphQL data on React front-end using Axios?

I want to know how to query data from the WP GraphQL plugin using Axios on a React front-end. I have a headless WordPress installation with the WP GraphQL plugin installed (that part is working great), but I need help understanding how to query the post data on the front-end of the site, which is built in React. My impression is that I can call Axios inside of a componentDidMount() method, and beyond that idea, I am stuck. GraphQL endpoint: …
Category: Web

Headless WordPress – Issue with plugin path

Working on my first decoupled site. Backend is handled by WordPress and lives on the subdomain admin.mydomain.com and the frontend lives at mydomain.com. The first issue I saw with the headless approach, was that all permalinks referred to admin.mydomain.com. I wanted to change that so that the backend referenced to my frontend. So I changed my config from: WP_HOME='http://admin.mydomain.test' WP_SITEURL='http://admin.domain.test/wp' to: WP_HOME='http://mydomain.test' WP_SITEURL='http://admin.domain.test/wp' which sorted my issue with the permalinks, but now I'm getting console errors on the WP dashboard …
Category: Web

How do I make reusable content blocks for header and footer when using Wordpress headless with another front-end?

I'm setting up a Wordpress project with Gatsby as frontend, and also using ACF for content. But I wonder how you would setup global content parts like header, footer, or any other kind of content that is being used globally throughout the website? For example both HOME and ABOUT pages need to have their "own" content, but also shares some specific blocks with same content. I need to be able to edit the content for my header like setting up …
Category: Web

How do I get the intended post type of a revision post?

I have a headless Wordpress instance with multiple custom post types. The build takes a few minutes, so I'm building a way to display drafts by fetching the latest revision via an API, like so: $revision = wp_get_post_revision($id); wp_send_json($revision); I retrieve the revision just fine, but the post type is set to revision instead of my custom post type. This causes problems, because I need the intended post type in order to build up a valid response that I can …
Category: Web

Using Disqus with headless Wordpress setup?

Does anyone have any experience using Disqus with a headless WP setup? I am working on converting a standard WordPress blog to a headless front end, with the users using the standard WP back end in the normal way. The blog is currently managing comments with Disqus, which I would like to load on the new static front end. I read the instructions for setting up the Universal Embed Code, and am pulling in the post id as the page.identifier. …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.