Skip to content

wolfdevsllc/wd-export-by-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WD Export by Search

A WordPress plugin to search any string across posts, pages, and custom post types — including custom fields, Elementor data, and page templates — preview matches in a sortable table, and export to CSV.

Built for content audits, domain migrations, and bulk URL tracking on sites where the standard WP search just isn't enough.


Features

  • Three match modes
    • Contains — default LIKE search; matches anywhere in the text.
    • Exact phrase — whole-word match using a POSIX word-boundary REGEXP.
    • Regex — full MySQL REGEXP, validated server-side before running.
  • Deep content search — title, content, excerpt, all custom fields (including _elementor_data, content, _wp_page_template, slide_template), across any selected public post types.
  • Live preview table — sortable columns, in-place filter, post-type filter, per-row Edit / View links, and post-type badges.
  • Chunked AJAX loading — results stream in 50 at a time with a progress bar; large sites no longer hit PHP / web-server timeouts. Cancel any time.
  • Client-side CSV export — generated from the loaded preview, so exporting is instant and never re-queries the database. Includes a UTF-8 BOM for clean Excel rendering.
  • Clean admin UI — no shadows, no gradients, custom select arrow, SVG sort indicators.

Installation

From the zip

  1. Download the latest release zip.
  2. In WordPress, go to Plugins → Add New → Upload Plugin and upload the zip.
  3. Activate the plugin.

From source

git clone https://github.com/wolfdevsllc/wd-export-by-search.git \
  wp-content/plugins/wd-export-by-search

Activate WD Export by Search in the Plugins screen.


Usage

Go to Tools → Export by Search.

  1. Enter a search string.
  2. Pick a match mode:
    • Contains for substring matching (e.g. old-domain.com).
    • Exact phrase for whole-word matching (e.g. office won't match officer).
    • Regex for MySQL REGEXP patterns (e.g. ^https?://(old|legacy)\.).
  3. Select one or more post types to search.
  4. Click Search. Results stream into the table with a progress indicator; click Cancel to abort.
  5. Sort, filter, or refine with the post-type dropdown, then click Export CSV to download.

The CSV columns are Post Title, Post Type, Post URL.


Match modes in detail

Mode SQL behavior Example Notes
Contains LIKE '%term%' office matches "head office", "officer", "office space" Fastest. Indexed-friendly on small fields.
Exact phrase REGEXP '(^|[^[:alnum:]_])term($|[^[:alnum:]_])' office matches "head office", but not "officer" Uses POSIX classes — works on MySQL 5.7, 8.x, and MariaDB.
Regex REGEXP '<pattern>' ^https?://(old|legacy)\. Pattern is validated against SELECT '' REGEXP %s before the main query — invalid patterns return a clean error.

Performance note: Regex on large wp_postmeta tables can be slow because indexes aren't usable. Prefer Contains or Exact phrase when possible.


How it works

  • Search. A custom AJAX endpoint (wp_ajax_wdes_search_posts) runs WP_Query with two extra hooks:
    • posts_search — overridden to use REGEXP when match_mode is exact or regex.
    • posts_where — adds an EXISTS subquery against wp_postmeta so the search reaches custom fields and Elementor data, while excluding hidden meta keys (_underscore_*) other than the known builders.
  • Pagination. Each request returns 50 results plus total, total_pages, and done. The frontend loops with await + AbortController, accumulating results into the table.
  • Export. CSV is built in JavaScript from the already-fetched results — no second round-trip and no server-side timeout risk on the export step.

All AJAX calls are protected by check_ajax_referer and current_user_can('manage_options').


Requirements

  • WordPress 5.0+
  • PHP 7.2+
  • MySQL 5.7+ or MariaDB 10.0.5+ (for REGEXP modes)

Development

The plugin is small enough to need no build step:

wd-export-by-search/
├── wd-export-by-search.php   # Plugin bootstrap, AJAX endpoints, query filters
├── admin.js                  # React (wp.element) admin UI
├── admin.css                 # Admin styles
└── readme.txt                # WordPress.org plugin readme

JS uses wp.element (React) and is loaded as a module-free script via wp_enqueue_script. There's no bundler — edit admin.js and reload.

To package a release:

zip -r wd-export-by-search.zip . -x ".git/*" ".git" "README.md"

Changelog

1.1

  • Match modes: Contains, Exact phrase, Regex
  • Sortable, filterable results preview table with per-row Edit / View links
  • Chunked AJAX search with progress bar and cancel
  • Server-side regex validation
  • Client-side CSV export with UTF-8 BOM
  • Refreshed admin UI

1.0

  • Initial release.

License

GPL-2.0-or-later. See LICENSE.


Credits

Built by WolfDevs.

About

Searches for a specified string in posts, pages, and custom post types, then exports matching URLs as a CSV

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors