How can I find out what pages and post on a site contain a particular reusable block?

Typically, to find content on a site, I issue wp db search *itemlookingfor* (like the post ID, part of a file name, or a word)


wp db query 'SELECT ID FROM the_posts_table WHERE post_content LIKE "%itemlookingfor%" AND post_status="publish"'

In my case, I used the reusable block's ID and no results were returned for either command. I replaced the ID of the reusable block with other common words on my site and results were returned so I think it's something special with reusable blocks.

Ideally, I'd like to use a wp-cli command or failing that, a sql command to search my database.

2 Answers 2


Those commands do work now after I stepped away for a few hours from the problem; so it was something on my end.

In my examples in the question, You can substitute the reusable block's post_id with the itemlookingfor to obtain the pages that contain your reusable block.


I can run wp db query for blocks I've created with ACF without issue. I assume this would work for any block ID. Eg:

wp db query 'select id, guid from wp_posts where post_content like "%acf/cta%" AND post_status!="inherit"'

You can also use the search-replace command in a sideways way to retrieve block content. Here's a method I used for finding the string "acf/cta" and printing it and the following 400 chars from the found string to a log file (I was trying to get block options).

wp search-replace "acf/cta" "whatever" --dry-run --log --before_context=0 --after_context=400 > cta.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.