Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment
<?php
/* 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_title();
    the_content( 'Read the full post »' );
endwhile;



?>

I have tried and got the solution.

share|improve this answer
add comment

Your Answer

 
discard

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.