Automatically categorize your WordPress blog posts using Google Gemini.
- Categorizes blog posts using AI (Google Gemini)
- Supports multiple output formats: XML and CSV
- Allows multiple categories per post
- Outputs post ID, title, categories, and edit link in CSV
- Supports category validation and batching
Create a .env file in your project root:
GOOGLE_API_KEY=your-api-key-here- Log in to your WordPress dashboard
- Go to
Tools→Export - Choose
Posts - Download the
.xmlfile
Run the script with:
deno run --env-file=.env --allow-env --allow-read --allow-net --allow-write index.tsYou’ll be prompted to:
- Select the XML file you exported
- Choose one or more export formats (XML, CSV)
- Provide allowed category slugs (e.g.
news, memory-care, senior-life) - Provide output file paths (or accept the default suggestions)
Once complete:
- Delete existing posts from WordPress (optional but useful for clean import)
- Import the new XML using
Tools→Import→WordPress
If using CSV, you can use the WP All Import plugin to import instead.
The CSV includes:
post idpost titlecategories(pipe-separated)edit link(based on the site URL from the XML)
If you don’t want to install Deno, use the precompiled version:
Make it executable and run it:
chmod +x wp-blog-post-categorizer
./wp-blog-post-categorizerEnter the path to the WordPress XML export file:
> exports/posts.xml
Select export formats:
✔ XML
✔ CSV
Enter XML output file path (or leave blank for default):
> exports/posts.out.xml
Enter CSV output file path (or leave blank for default):
> exports/posts.out.csv
Enter allowed categories:
> news, memory-care, senior-life