How to Run PHP Code in WordPress

Hello everyone, Larry Snow here with another quick tutorial on how to run PHP Code in a WordPress Page or Post. I was presented with a challenge to retrieve data residing on a MySQL database and have it displayed on our client’s page. I decided to use PHP code since WordPress is built upon PHP but surprisingly without a plugin WordPress ignores the PHP code.

If you know of another way to run PHP code in WordPress post in the comments below


28 thoughts on “How to Run PHP Code in WordPress

  1. I know this is an old video and this is definitely useful on a site where you can trust users, but if someone with malicious intent got a hold of a site with this plugin they could access the WordPress config files and seriously mess things up.

  2. Hi Philip – got your other post, deleted it accidentally 🙁 I see what you are asking now – I don't think there is a search plugin to search the database, I'd try using the text plugin to set up a search box that when submitted would go to a page that has the sql query code to search the database and show the results. If you can't do it as a text plugin, set up a separate page for the search box.

  3. i have a question sir do you know any search box plugin similar to web browser text finder found in (ctr+F) because if i display a long list of personal info from my database im gonna need a text search box in my web page without pressing ctr+F

  4. Hi Martin thanks for the kinds words. Not sure if I can answer your questions, but feel free to post and if I can answer them I will. I'd suggest though, and you may have already done this, to go to WordPress(dot)org forums for answers to your questions.

Leave a Reply to Larry Snow Cancel reply

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