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 ToolsExport
  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 ToolsImportWordPress

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

 
 
 

Contributors