• I’ve created a block theme using react-wordpress. It works fine in development, because I’m mounting the theme files directly to /var/www/html/wp-content/themes/my-theme

    Now that I’m trying to upload the theme through WordPress’s GUI, I’m getting an error that either index.php or templates/index.php needs to exist. Adding these files to my build will allow the theme to be uploaded, but it will not work because at the end of the day the theme is exists in index.js.

    I’m unsure if there’s something missing from my setup (I spent a lot of time cobbling this stack together from random internet sites) or if this is an actual bug. Any help would be much appreciated.

Viewing 1 replies (of 1 total)
  • It seems that the issue you encountered is primarily due to WordPress’s mandatory requirements for a theme’s basic structure, particularly the need for an index.php file as an entry point, even if your theme is based on a React frontend architecture.Solution: Create a Basic index.php

    Even though your theme is primarily built around a React-based index.js structure, you can add a simple index.php file in the theme directory to ensure compatibility with WordPress:

    <?php
    // This file is required by WordPress for theme compatibility.
    // Redirect all requests to your React app's entry point.
    include_once('index.html');
    ?>
    

    If you want to route all requests to React, ensure that there is a static index.html file in the theme directory to load your React application.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.