The wpdb class, accessed via the $wpdb global variable, is used to interact with the WordPress database

learn more… | top users | synonyms

1
vote
1answer
695 views

wp-admin post.php JavaScript Links Not Working

I just recently noticed in my backend admin panel none of the dynamic JavaScript links will open or work at all. This includes the 'Edit' links next to Status, Visibility, and Scheduled. Also the slug ...
1
vote
1answer
435 views

Using WPDB class

I want to use the wpdb class on my external page not associated with wordpress. I tried to include the following on the php file: // include wordpress functions include( $_SERVER['DOCUMENT_ROOT'] . ...
0
votes
2answers
62 views

wpdb result arrray inside an array

I am trying to run a database query as below: $id = $_GET['id']; $query = 'select * from '; $query .= $wpdb->get_blog_prefix() . 'fxdescription '; $query .= 'where id= '.$id; $currency = ...
1
vote
1answer
135 views

Modify the structure of data returned by $wpdb

Modify the structure of multidimensional array outputed by SQL via $wpdb The output that I need from $wpdb is easily achievable by running multiple queries within foreach. However, I am trying to ...
0
votes
2answers
1k views

wpdb update multiple row?

I need to change the meta value of all users at once. Seem there are no api for this,except using custom database query. This is my code: $matches = array('meta_key' => 'user_token'); $data = ...
4
votes
1answer
160 views

Theoretical Multi-Server WordPress Setup with Shared Users

The organization I work for would benefit if we could take the existing WordPress installations that are located on several (~5) different servers and be able to use a universal database with the ...
1
vote
1answer
42 views

Where to store the name of a custom table?

I'm extending the $wpdb object with properties for my custom tables. function setup_wpdb() { global $wpdb; // Create properties for custom tables $wpdb->my_plugin_table1 = ...
2
votes
2answers
1k views

Creating a Front-end based User Search

I am working on a membership site which requires a front-end user search. I have been searching for an answer like a mad man, and I could really use some help! While there are several plugins that ...
2
votes
1answer
316 views

Get terms that contain posts that in turn belong to other terms?

So I have custom taxonomy called "shape" and another one called "color". If I want to get the list terms under shape that contain posts that are also present in terms under color, how do I do that? ...
0
votes
1answer
271 views

wpdb inside foreach loop only returns first result - 2 other similar cases found

@Milo Problem solved, found spaces in the array $arrname. I was trying to get post id using post_name. First of all I stored all post_name in an array an then loop through the array to use the key ...
0
votes
1answer
252 views

How to use remote db tables in current config? [duplicate]

Possible Duplicate: Shared Members between two different wordpress installations with different databases For example I have 2 different wordpress installations with different domains and ...
1
vote
1answer
2k views

ob_end_flush error when using wpdb in plugin

I created a small plugin to test database interactions in wordpress. I have a small function that inputs the arguments to the table. If i call my function in a themefile it inputs my test values to ...
0
votes
1answer
270 views

WP_Query search by multiple meta key and distance

I am having two meta keys, longitude and latitude, and what I am trying to do is the equivalent of the google store location algorithm for distance, in wp_query: SELECT id, ( 3959 * acos( cos( ...
1
vote
2answers
464 views

$wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies

It's easier if I made an example: I have a custom post type MYPOSTTYPE, with 3 taxonomies TAX_1, TAX_2 and TAX_3 If I have 3 terms: 'TERM_TAX_1' in TAX_1, 'TERM_TAX_2' in TAX_2, and 'TERM_TAX_3' in ...
2
votes
1answer
93 views

How do I batch create revisions of all posts?

I cleaned up an old-site from pasted tags, manually created lists, etc, and I'd like to keep the old posts as "revisions", so we can easily "compare" with the old posts and retrieve/revert the ...
0
votes
1answer
711 views

Get post featured image id with $wpdb

I'm not a sql expert, but with some help and copying from queries I've found on the web I got this working one that gets the 20 closest places (custom post type) to a specific latitude and longitude ...
2
votes
1answer
1k views

Get multiple custom field values in a $wpdb query [duplicate]

Possible Duplicate: How to query posts based on lat-lng coordinate as post meta? I want to create a $wpdb query that select the closest places (custom post type) near the current ...
1
vote
0answers
584 views

$wpdb->get_results() returns good result only in first foreach iteration

I've got strange issue when I am using $wpdb->get_results() in content-single.php in Twenty Eleven theme. $wpdb->get_results() returns proper values only in first loop iteration. I've got simple ...
1
vote
1answer
722 views

$wpdb not being defined in function: Fatal error: Call to a member function query() on a non-object

For some reason the $wpdb object is not being defined in one particular function. I have four other functions in the file that are using $wpdb and all are working fine except this one simple delete ...
1
vote
1answer
352 views

Converting the_content string to an array?

I have created a custom taxonomy, this taxonomy is dedicated to image attachments, when I upload my images $post->post_content returns a string like: '[caption id="attachment_98" align="alignnone" ...
0
votes
1answer
116 views

Compare string with post id in wpdb and do stuff when match is found

I'm looking for some help tying in with the wpdb to compare and change certain values. I'm very novice with mysql handling so I really appreciate any help on this matter! What I want to do is to go ...
2
votes
1answer
2k views

How to use wildcards in $wpdb queries using $wpdb->get_results & $wpdb->prepare?

I am attempting to make a custom search for BuddyPress groups. Here is my method: public function search_groups($string){ global $wpdb; $results = $wpdb->get_results($wpdb->prepare( ...
1
vote
1answer
338 views

Wordpress choose wrong database

I have 2 databases. When I include the database connection (with a include('filename.php');) wordpress acts really strange. I can't login, the wordpress username and password is right but it tries to ...
3
votes
2answers
935 views

Display data from a non wordpress database on a page template

I am using a sql query to access information to display on a wordpress page by adding the below code to a page template. I know the query works as I've tested it in phpmyadmin. $rows = ...
1
vote
0answers
36 views

Code only works every other time its run

This code below works fine as long as I leave the $wpdb query commented out. However, I'm trying to clear the current settings before I write the new ones into the db. That's the purpose of the $wpdb ...
0
votes
1answer
69 views

Nothing happens on Wordpress Update command

I made a function in Wordpress, which should update one field status to 0. But no changes are made to the database. I don't know what is the reason. Can someone please help. I tried looking into ...
1
vote
2answers
1k views

Increment value (value = value+1) of $wpdb->update

This sql query $wpdb->query("UPDATE log SET total=total+1 WHERE id='1')"); How do I turn it into $wpdb->update() statement? Ex. $wpdb->update('log', array('total'=>'total+1'), ...
-1
votes
1answer
802 views

Checking if meta_value exists for any user

I'm using gravity forms for a sign-up form and I set up a hidden field that is automatically filled with a random string generated and passed to the form by ...
-1
votes
1answer
534 views

How to combine jQuery in-place editor with $wpdb->update

i am trying to use jQuery in-place editor (http://code.google.com/p/jquery-in-place-editor/) on WordPress to update certain values of a custom made table in my database. I am not really skilled with ...
1
vote
3answers
685 views

Why am i getting this error? WordPress database error: [Query was empty]

I am using Wordpress 3.4.2, latest version! I have no plugins installed except the one that I am writing. So Here's the deal, I'm reading a json feed and i'm trying to import its content into a ...
0
votes
1answer
157 views

Creating and Using Tables in the Wordpress Database

I plan on having over 2,000 pages per subject on my WordPress website and since each subject will require custom page types I would like to create tables for each subject in the WordPress Database. ...
0
votes
1answer
1k views

$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

I have a custom post type 'event', a custom meta field 'event_date' and a custom taxonomy 'locations'. I want to query $wpdb to retrieve posts in this way posts must be of the 'event' post type ...
0
votes
3answers
433 views

pull custom fields values from wp-database in a nested foreach loop

I am trying to display custom fields on my template values of which i am pulling from postmeta table doing something wrong with a loop or not writing the foreach args correctly not sure whats the ...
1
vote
2answers
328 views

Join new table with SQL query

I created a plugin with a new table (wp_soundcloud) and I need to retrieve the data from that new table along with the post data. Here is my query: $querystr = " SELECT $wpdb->posts.*, ...
1
vote
3answers
342 views

Detect featured image among the attached images

I use the following code to extract the attached images from a post with ID: $args = array( 'post_type' => 'attachment', 'post_parent' => $product_id, ...
0
votes
1answer
367 views

populate select options from extra mysql table data

hi guys i am trying to populate a select element with options from the data in one of my sql tables heres what i have so far: <? $SQL = "SELECT * FROM pt_country ORDER BY name"; $rs = ...
1
vote
1answer
489 views

How to split the a table in database?

Is there any option to split the tables in more tables in different databases? The problem is that my the wp_posts table is to big and it takes a lot of time to show in the Dashboards... (more than 20 ...
2
votes
1answer
791 views

Problem in creating table through plugin code

I'm using the following code to create the database table using plugin. However, the table is neither getting created nor I'm getting any error message. The code is as follows: global $wpdb; ...
4
votes
1answer
347 views

find a random blogid across my multisite network that has at least one post published

I need to find a random blog across my multisite network that has at least one post published of a certain post_type, and return its blogid as a variable so I can use it in a switch_to_blog() call. I ...
1
vote
1answer
117 views

Using WPDB to output raw XML fails because of wp-blog-header.php

I'm coding a plugin. One particular file of this plugin is supposed to pull data from the plugin's custom DB table, and output it with minimal processing as raw XML. The problem is, to get the WPDB ...
0
votes
1answer
727 views

Creating an auto result search bar

I'm trying to create a search bar that will show me titles of posts when the user types into the text field. I'm completely new to this and I really don't know how to go about doing this. What would ...
0
votes
2answers
121 views

Build index page from custom fields

Im starting to delve deeper into Wordpress custom fields and wanting to replicate this page in Wordpress: http://www.clubsact.com.au/corporate/index.php So my site is not tightly structured to a ...
1
vote
0answers
190 views

Query most popular terms by taxonomy over 2 week period

I have written SQL for a query that pulls the most used taxonomy terms for selected taxonomies that are published, do not have a parent post are not in a comma separated list over the past two weeks ...
0
votes
1answer
290 views

Problem adding 'has-children' class to wp_nav_menu

According to a number of references online, I should be able to use the following function to add the class, has-children, to menu items that have children under them: function ...
-2
votes
1answer
35 views

How to dispaly post informations (such as titles) in an admin plugin menu page?

I'm trying to develop a WP plugin to show post(or page) related information (such as show all post title in a list) in an admin menu page. I tried to use "The Loop", but it seems like "The Loop" ...
0
votes
1answer
107 views

Are there risks associated with using wp_options table using wpdb to update theme options

I am making a theme and it has so many options that need to be updated via jquery's ajax.Having looked at ways of updating wp_options via ajax,i have hypothesised that updating the wp_options table ...
2
votes
2answers
428 views

Database slowdown after update to 3.4.1

I own a wordpress installation, and Updated to 3.4.1. After the upgrade, I got a very strange slowdown to my wordpress. After all, I used the define('SAVEQUERIES', true); in my wp-config.php with ...
1
vote
0answers
163 views

wpdb updating record in wordpress with json adds extra array elements

This is killing me - I keep getting magical array elements added to my updated array in WP. For example if my query is (var_dumped below): string(70) "UPDATE wp_mytable SET already_played = '[9]' ...
1
vote
1answer
326 views

How Can I Use $wpdb in PayPal IPN file?

I'm currently writing a plugin that requires the PayPal IPN, since the IPN is not inside the main plugin file, I have no way to use $wpdb. If you know a way to do this that will work with all ...
0
votes
1answer
104 views

Different sql queries count indicator on the main page [closed]

I use w3_total_cache plugin. But i can`t understand what is going on sometimes. I have enabled database caching and debug info at the bottom. Sometimes on the main page 90-96 db queries, sometimes ...