• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Dev Tips / WP CLI Find in Post

WP CLI Find in Post

Last updated on August 9, 2024 by Sal Ferrarello

Sometimes I want a list of blog posts that contain a certain string. For example, I might want a list of all blog posts that contain the word “kazoo” using WP CLI. My favorite tool for this is wp post list.

While the documentation for wp post list doesn’t list search specifically, it does say

Display posts based on all arguments supported by WP_Query().

One of the arguments WP_Query() accepts is s (for search), so we can run

wp post list --s='kazoo'

and get the list of posts with the word kazoo in it.

+------+---------------------+-----------+---------------------+-------------+
| ID   | post_title          | post_name | post_date           | post_status |
+------+---------------------+-----------+---------------------+-------------+
| 9873 | WP CLI Find in Post |           | 2024-08-09 14:37:10 | draft       |
+------+---------------------+-----------+---------------------+-------------+
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Dev Tips, Solution Tagged With: WordPress, wp-cli

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in