Does the WordPress installation has to use an exclusive database? I'm building a website with custom pages, that access a MySQL database. But the site will also have a WordPress installation. Can I use the same database unique for WordPress and the custom pages?
Does the WordPress installation has to use an exclusive database?
If there are no table name conflicts, WordPress can share a database. Preventing conflicts is just a matter of setting a database prefix on install. By default, that prefix is wp_
but you can change it to anything you want within reasonable character limits. It should be no problem.
Yes.
Any custom site can be built within a WordPress installation, as it's back-end is completely coded with PHP, and MySQL. But for many reasons you are not recommended to use MySQL queries in WordPress, but to use $wpdb
class refrerence. And you can make as many as pages you need by using WordPress custom Page Templates.
You can create a page template by simply putting the following codes into a new .php
file:
<?php
/*
Template Name: My Custom Page
*/
Then you can create a new page in WordPress admin panel and can choose the template easily. And this Q & A will also help you achieve something you may want.
Even you can make new tables within your WordPress db, and can add/edit/delete/query certain things from the new custom tables. But for always, using $wpdb
is recommended for many reasons(you know now).
-
Thanks for your valuable information. I'm not building the custom part as custom WP pages, but now after this answer I'll be considering doing it, since I didn't know much about these capabilities. Thanks a lot for clarifying. – wid Aug 24 '13 at 16:21