Title: Using wpdb-&gt;wp_query with wp_remote_post
Last modified: August 21, 2016

---

# Using wpdb->wp_query with wp_remote_post

 *  Resolved [big_s](https://wordpress.org/support/users/big_s/)
 * (@big_s)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-wpdb-wp_query-with-wp_remote_post/)
 * Hi,
 * I am using the HTTP API wrapper function wp_remote_post on Site A to trigger 
   a function in the functions.php file of a separate wordpress installation on 
   Site B (two different servers).
 * The function on Site B triggers fine and returns values as expected. Now I wish
   to return information from a custom table in the wordpress database of Site B.
   I am currently trying to use the following in functions.php on Site B:
 *     ```
       add_action('template_redirect', 'process_post_request');
       function process_post_request(){
       	if( $_POST['action'] == 'get_job_posts' ){
       		global $wpdb;
       		$jobs_list = $wpdb->wp_query( "SELECT job_title FROM $wpdb->wpjb_job LIMIT 5;" );
       		if ( $jobs_list ){
       			// do stuff with results of query here
       		}
       		die();
       	}
       }
       ```
   
 * The problem is that when it hits the line containing the query it throws an error:
 * > Call to undefined method wpdb::wp_query()
 * Why isnt this query call being recognised? What am I missing?
 * Any insight much appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-wpdb-wp_query-with-wp_remote_post/#post-3835174)
 * Try this
 * Change
 *     ```
       $jobs_list = $wpdb->wp_query( "SELECT job_title FROM $wpdb->wpjb_job LIMIT 5;" );
       ```
   
 * To
 *     ```
       $jobs_list = $wpdb->query( "SELECT job_title FROM $wpdb->wpjb_job LIMIT 5;" );
       ```
   
 * [http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database](http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database)
 *  Thread Starter [big_s](https://wordpress.org/support/users/big_s/)
 * (@big_s)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-wpdb-wp_query-with-wp_remote_post/#post-3835178)
 * Haha thanks Rajesh, such a simple things I couldn’t see it!
 * Nice one 🙂
 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-wpdb-wp_query-with-wp_remote_post/#post-3835180)
 * You’re welcome. Glad I could be of help.
 * Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using wpdb->wp_query with wp_remote_post’ is closed to new replies.

## Tags

 * [wp_remote_post](https://wordpress.org/support/topic-tag/wp_remote_post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/using-wpdb-wp_query-with-wp_remote_post/#post-3835180)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
