Templates and pulling data from my own database (not wordpress one)
I'm pretty new to wordpress. I have read a lot about templates, template pages, etc... and I would really apreciate if someone could confirm my thoughts, ideas about how to build my Homepage with wordpress (I won't be using it for blooging, but my enterprise webpage).
The main problem is that I need to have a page, where a little list of items will be shown. After one of them is clicked another page will be shown with information about the item like a pic, short description, etc... etc... This Item information page will be using a template page where data from my own CMS database has to be inserted in the template holes.
All examples I have seen in wordpress are about pushing data in wordpres开发者_高级运维s database and showing it using WP API. But, what about if I just want to use wordpress as a template system, with all its plugins, etc... and pull the data needed to be shown from another database (our CMS)?. Could anyone suggest best practices for this, or a better aproach?.
Thanks in advance.
is your wordpress database in the same database as your own? ie: you can access the wp tables along with all your other tables? if so you can use the wp api, to connect,
using the normal connection methods..
if the tables are not in the same database but located under the same account on your host, you could use the same method shown in this thread...
$mydb = new wpdb('username','password','database','localhost');
$rows = $mydb->get_results("select Name from my_table");
echo "<ul>";
foreach ($rows as $obj) :
echo "<li>".$obj->Name."</li>";
endforeach;
echo "</ul>";
if the database is in another location, outwith the current server just change the localhost to your server ip and port to connect, ie:
$mydb = new wpdb('username','password','database','192.168.1.1:6807');
good luck
Marty
精彩评论