I'm using https://www.npmjs.com/package/@wordpress/env to set up a local docker-based WordPress development environment, which has been working great so far. I'm trying to build a script using WordPress's CLI that sets the permalink structure to '/%postname%/', so that visiting /sample-page would work without any manual setup.

I've tried all of the following commands:

wp-env cli wp option set permalink_structure '/%postname%/'
wp-env cli wp rewrite structure '/%postname%/'
wp-env cli wp rewrite flush --hard

My problem is that even though the navigation bar shows a link to http://localhost:8888/sample-page/, actually trying to visit that page yields a "Not Found / The requested URL was not found on this server." page in response.

This situation only resolves itself the moment I visit the WP Admin Settings Permalink pages (no save changes click, and simple logging in doesn't fix it either), but I'd like to do this through the CLI, which I hope would be possible for automating site setup.

Any advice?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.