Keyword Filter

By williamlong

10+ active installationsVersion 1.1.0

Replace chosen keywords in post content with your own words.

Description

Keyword Filter replaces selected keywords in post content with the words you specify. It works by applying a WordPress filter to post content at display time, so the original post is kept in the database and only the output is changed.

Features:

  • Case-insensitive matching for Latin text.
  • Support for multibyte characters, including Chinese.
  • Safe, single-pass replacement that preserves UTF-8 text.
  • The replacement map can be customized without editing plugin code.

The default replacement map ships with the plugin. To set your own map, add the following to your theme’s functions.php or a custom plugin:

add_filter( 'keyword_filter_map', function() { return array( 'old' => 'new', 'example' => 'sample' ); } );

The array keys are the words to find, and the values are their replacements. Return an empty array to disable filtering.

Installation

  1. Upload the plugin folder to the /wp-content/plugins/ directory, or install it through the WordPress Plugins screen.
  2. Activate the plugin through the Plugins menu in WordPress.
  3. Optional: use the keyword_filter_map filter to define your own replacements.

FAQ

Does this change posts in the database?

No. Filtering happens only when content is displayed. The stored post is never modified.

How do I add my own replacements?

Use the keyword_filter_map filter, as shown in the Description section.

Changelog

1.1.0

  • Replaced byte-based string replacement with a UTF-8 safe approach.
  • Added the keyword_filter_map filter for custom replacements.
  • Fixed plugin header metadata and license information.
  • Added compatibility with current WordPress and PHP versions.

1.0

  • First stable version.