WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the Sleek child theme from Studio Press and want to do a PHP call to this external database for it to display just like this link: http://www.escort332.org/tuskegeecadets.php . The Theme page is this full width page: http://escort332.org/wordpress1/tusk...skegee-cadets/. Is there a way to add the PHP code that links to the database in the page itself? I would also need access the database for other pages as well. Is this possible in the Genesis framework or child themes. Any help would be greatly appreciated.

share|improve this question

I can't bee too specific answering your question, but you can certainly use a $wpdb instance to access another database:

$db = new wpdb('user', 'password', 'dbname', 'dbhost');
$results = $db->get_results('..query..');
share|improve this answer
Hey!, how did you wpdb instance from.. did you call it from headers or any other thing. – Rafee Nov 21 '12 at 17:25
/* get the database configuration automatically starts here */

$server_url = $_SERVER["SERVER_NAME"];
$doc_root = $_SERVER["DOCUMENT_ROOT"];

require($doc_root . '/wp-config.php');

$post_id = 5;

query_posts( 'p=' . $post_id );

global $more;
$more = 0;

// the Loop
while (have_posts()) : 
    the_content( 'Read the full post »' );


I have tried and got the solution.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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