WordPress – Find text within all posts

wordpress blue and white and grey logo
wordpress blue and white and grey logo

Estimated reading time: 3 minutes

We recently started to update all of our old posts that contained our old domain name of techygeekshome.co.uk.

To do this, we needed to find all of the posts that actually have this in both the post content itself and also any links or code within the source of the post.

This could have been a painstaking process but we used a method of getting the information we required from our WordPress database using phpMyAdmin and a simple SQL query.

Instructions

If you want to get a list of posts that has a set of text within it, then you can follow our simple guide.

Please note: You should always backup your database before doing anything – you mess it up, do not blame us!

You should first of all login to your cPanel and then get into your phpMyAdmin portal. From here you need to click into your database for your WordPress installation of the left hand side.

Once you are in the correct database, click on the SQL tab:

phpMyAdmin SQL Tab
Click to enlarge

Then in the query box below it, you should type in this query:

SELECT * FROM wp_posts WHERE post_content LIKE '%techygeekshome.co.uk%'

where:

  • wp_posts = the name of your posts table
  • ‘%techygeekshome.co.uk%’ = the text that you want to find in the WordPress database

You should then press the Go button at the bottom right:

phpMyAdmin Query Box
Click to enlarge

This will then go off and find all the posts with the stated text in it:

phpMyAdmin Results Posts
Click to enlarge

Now you have pulled the data from the SQL database, you now can export that data to CSV format so that you can open it in Excel.

Just tick the Show all tick box:

phpMyAdmin show all rows
Click to enlarge

If you get a popup warning you about it pulling a lot of data, just click on the OK button:

phpMyAdmin Pop Up Box
Click to enlarge

Then scroll to the bottom of the page and you will see the Export option:

phpMyAdmin Export Option
Click to enlarge

This will then take you to the exporting page options, from the drop down menu you can select CSV and click the Go button:

phpMyAdmin Export Options
Click to enlarge

This will then export the data in to a CSV file which you can now go ahead and open in Excel.

Feedback

If you have any questions or comments on this guide, please feel free to leave us a message below in our comments section.

Click to rate this post!
[Total: 0 Average: 0]

Share this content:

Avatar for Andrew Armstrong

About Andrew Armstrong

Founder of TechyGeeksHome and Head Editor for over 15 years! IT expert in multiple areas for over 26 years. Sharing experience and knowledge whenever possible! Making IT Happen.

View all posts by Andrew Armstrong

Leave a Reply

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