I created WP page and I need to show a table with some information. This information is hold in a database (hosted on the same server).

To be more detailed, I'll try to split my question. I'm new to wordpress and don't estimate it potential (concept) yet.

1) If I need to show my own data (few related tables, with option of user filtering data) in a table on a wordpress page. Is there special way to make new tables in WP DB (for my own data), or I need to create a separate database instead?

2) If I have to create a separate database (for example, MySQL, hosted at the same server as the WP DB). How can I connect to it from inside WP page? I have to just make PDO object, connect to db with host/dbname/user/pass, prepare and execute a query? Or I can "register" this new database, for example in a config file (writing there host/dbname/user/pass, not to write this every time I need to fetch data on a page). Also, is there something like a framework - to easily fetch data (describe a model before, then fetch data and send it to the page)?

3) How to execute php scripts in WP page? In admin panel, there is only WYSIWYG/HTML editor of a page.

  • 1
    You'll have to give more than just this. How was the data saved, where did it came from, in which table does it resides. What kind of data is this. Is this even Wordpress related. Please file an edit with the required information. Pure SQL queries are not recommended. Oct 27, 2014 at 14:39
  • Thanks, I've tried to give more details about what I mean Oct 27, 2014 at 15:10

1 Answer 1


1) It is easy to create tables in WP. I suggest making a plugin to handle this for you. See the codex for more info: https://codex.wordpress.org/Creating_Tables_with_Plugins

2) Again, I suggest using WP to handle this for security purposes. As you stated, you would have connection details that could potentially be exploited.

3) I think there are plugins for this. Another way is to write your PHP into Theme files so that users will not be changing this. It is not good practice to store your PHP code in the database.

Your Answer

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

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