wordpress-rest-curl/README.md
2026-07-30 17:44:40 +02:00

38 lines
1.4 KiB
Markdown

# wordpress-rest-curl
CLI tool for submitting posts to WordPress through its REST API using curl.
## Install
### WordPress
Application Passwords are built into WordPress core since 5.6 — no plugin needed.
Go to Users → Profile → Application Passwords on your site, generate a new
password for your user, and note it down. Your site must be served over
HTTPS for this to work.
### Local shell
Make sure you have `curl` and `jq` installed. If you want to enter text in
markdown format, install `python-markdown2` (`pip install markdown2` or your
distro's `python3-markdown2` package).
Create a config file `~/.config/wordpress-rest-curl/config.sh` from the `config.sh.template` file.
Copy the posting script to e.g. `/usr/local/bin/wordpress-post` so that you can run it from anywhere.
## Usage
* Run the script
* Text editor opens. Type your post, save it.
* Confirm the displayed post by pressing enter.
* Done!
### Options
* `--file PATH` — use PATH as the post content instead of opening `$EDITOR`.
* `--publish` — shortcut for `STATUS=publish`, posts live immediately.
* `--edit POST_ID` — update an existing post instead of creating a new one.
## Testing
`tests/run_tests.sh` runs post.sh against a local mock of the WordPress REST
API (`tests/mock_wp_server.py`) — no real WordPress install or network access
needed. Requires the same dependencies as the script itself (`curl`, `jq`,
`python3-markdown2`).