Skip to content

Instantly share code, notes, and snippets.

@dgowrie
Created June 27, 2019 02:35
Show Gist options
  • Save dgowrie/e8bbd6e18fe2befe968823a0ed52d249 to your computer and use it in GitHub Desktop.
Save dgowrie/e8bbd6e18fe2befe968823a0ed52d249 to your computer and use it in GitHub Desktop.
SQL query for string in WP posts content
-- Change wp_ to your database prefix
-- Change example.com to your domain
-- Change string to the text you want to search for
SELECT
ID as 'Post ID',
post_title as 'Title',
CONCAT('http://example.com/',post_name) as 'URL'
FROM `wp_posts`
WHERE post_type = 'post'
AND post_content LIKE '%string%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment