WP Manifestindependent plugin directory
manifest / content / wordpress-custom-taxonomy

Auto Assign Case Year and First Letter (Improved + Batching)

A WordPress plugin that automatically extracts years from post titles to assign a 'Case Year' taxonomy and organizes posts alphabetically. Includes a batch processor for existing content.

by Olayode Bolade · github.com/bolade-olayode/wordpress-custom-taxonomy

1stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/bolade-olayode/wordpress-custom-taxonomy/archive/refs/heads/main.zip

Auto Assign Case Year and First Letter (WordPress Plugin)

A lightweight WordPress utility that automatically organizes posts by analyzing their titles. Designed for legal cases, archives, or any library requiring chronological and alphabetical sorting.

Features

  • Automatic Taxonomy Assignment: Automatically detects and assigns terms to two custom taxonomies upon saving a post:
    • case_year: Extracts the year (e.g., "2024") directly from the post title.
    • first_letter: Assigns the first letter of the title (A-Z) for alphabetical indexing.
  • Smart Regex: reliably detects years (1900-2099) and handles title formatting (en-dashes, em-dashes).
  • Batch Processor: Includes a built-in tool under the "Tools" menu to process thousands of existing posts in batches to prevent server timeouts.
  • REST API Support: Registered taxonomies are visible in the WP REST API.

Installation

  1. Download the repository as a ZIP file.
  2. Go to your WordPress Dashboard > Plugins > Add New > Upload Plugin.
  3. Upload the ZIP and activate the plugin.

Usage

For New Posts

Simply write your post and publish. If the title is "State v. Doe - 2023 Appeal":

  • Case Year will be set to 2023.
  • First Letter will be set to S.

For Existing Posts (Batch Processing)

  1. Go to Tools > Assign Case Data.
  2. Click Run Next Batch.
  3. The tool will process 100 posts at a time until all content is organized.

Code Overview

  • Taxonomies: Registers case_year and first_letter.
  • Hook: Uses save_post_post to trigger on save.
  • Batching: Uses WordPress Transients to handle loop offsets/memory management.