Filter by post types and post status in post table

Open
#125 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
sql, wordpress
Domain
cli, databases

Research direction

Start with the wp search-replace command and trace how it selects posts, revisions, and post types. Clarify the intended semantics of the proposed status and post-type options, then define completion as restricting replacements to the requested values without changing excluded content; no files or tests are named in the issue.

Written by the indexing model from the issue text.

Description

wontfix

Feature Request

Describe your use case and the problem you are facing

I currently use search-replace for batch editing content (when the name of an event that we do has changed for example...)

There's been a couple instances where I would have preferred search-replace to only
edit the content that is currently published (post_status=published) not in past revisions; or only to only change in specified post_types (we updated the url structure for only one kind of custom post_type).

Describe the solution you'd like

I was wondering if it's possible to add an additional parameter to the search-replace command so that when search and replaces are made; the user can specify the
only affect the current revision of content in the wordpress database.
(Thinking aloud this could be done by filtering the post_status or post_type columns for specified values.

(I'd add an extra parameter like post_status=publish which would not update currently published content) using a parameter like --skip-post-status.
Example usage:
wp search-replace 'before' 'after' --skip-post-status=publish --recurse-objects --skip-columns=guid --skip-tables=wp_users

or to only edit certain post types like
--include-post-type-values=my_custom_post_type
Example usage:
wp search-replace 'before' 'after' --include-post-type-values=my_custom_post_type --recurse-objects --skip-columns=guid --skip-tables=wp_users

Filtering out the post_status and post_type columns for their values can be done using a SQL statement but adding this to wp-cli hopefully would be worth doing.

Dominant language
Gherkin
Stars
61
Forks
47
Avg merge
8m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wp-cli/search-replace-command

All issues in wp-cli/search-replace-command

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.