Skip to content

Solution-Agency/wp-post-categorizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WordPress Blog Post Categorizer

Automatically categorize your WordPress blog posts using Google Gemini.


✨ Features

  • 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

πŸ”§ Requirements

Create a .env file in your project root:

GOOGLE_API_KEY=your-api-key-here

πŸ“€ Exporting from WordPress

  1. Log in to your WordPress dashboard
  2. Go to Tools β†’ Export
  3. Choose Posts
  4. Download the .xml file

πŸš€ Usage

Run the script with:

deno run --env-file=.env --allow-env --allow-read --allow-net --allow-write index.ts

You’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:

  1. Delete existing posts from WordPress (optional but useful for clean import)
  2. Import the new XML using Tools β†’ Import β†’ WordPress

If using CSV, you can use the WP All Import plugin to import instead.


πŸ“„ CSV Output

The CSV includes:

  • post id
  • post title
  • categories (pipe-separated)
  • edit link (based on the site URL from the XML)

🧊 Precompiled Executable (Mac ARM)

If you don’t want to install Deno, use the precompiled version:

πŸ“¦ Download for Mac ARM

Make it executable and run it:

chmod +x wp-blog-post-categorizer
./wp-blog-post-categorizer

πŸ§ͺ Usage Example

Enter 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

About

Script to categorize WordPress posts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published