1

Am developed a website with word press and my url like this http://www.myhost/wp/

now i want to add a webpage like http://www.myhost/wp/guest/

the guest folder contains an index.php file

this file is fetching some data from wordpress mysql database.

the index.php files are shown below..

 <?php
 $user_count = $wpdb->get_var( "SELECT user_login  FROM $wpdb->adc_eng_users" );
 echo "<p>User count is {$user_count}</p>";
 ?>

i cant get the data from database table... how can i include the connection configuration with wp_config.php file

any body please help me

Thanks

1 Answer 1

2

Put below code at top of your index.php file

require_once( '../wp-load.php' ); 

This will include all the WP Functions and classes as well as all plugin files.

Sign up to request clarification or add additional context in comments.

2 Comments

require_once( '../wp-load.php' ); $query="SELECT post_content,ID FROM chelsa_tower_posts WHERE post_type = 'testimonial' ORDER BY id DESC LIMIT 1"; $result=mysql_query($query); $array=mysql_fetch_assoc($result); echo $array['post_content'];
It should work please try following code <?php require_once( '../wp-load.php' ); // Make sure the file path is correct and is includded $query="SELECT post_content,ID FROM chelsa_tower_posts WHERE post_type = 'testimonial' ORDER BY id DESC LIMIT 1"; $results = $wpdb->get_results( $query, ARRAY_A ); echo '<pre>';print_r( $results );echo '</pre>';

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.