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

learn more… | top users | synonyms

0
votes
1answer
75 views

How to optimize multiple insert into wordpress database

I had main file with my plugin and the another file with sql command. In the second file I create two tables and write data to one of them. But I have problem with. In my private computer everything ...
0
votes
2answers
47 views

Help setting up a sql query

I need to list out specific custom field items that contain an associated custom field entry. For example, the custom fields are named "type" and "food". I would like to list out all of the breakfast ...
0
votes
1answer
110 views

access JSON results from wordpress database with wpdb

I have JSON results from Google API added to to wp_options table. At this point I just need to echo the specific elements. Namely, the coordinates. The option_name I have is py_menu_item. One of the ...
0
votes
1answer
359 views

$wpdb->get_results not returning an array

I haven't really messed with $wpdb before, but I'm stuck hard on one part. I'm trying to get the values returned in an associative array. I've tried both of these $datarow = ...
0
votes
1answer
254 views

Query custom taxonomy for category including children

I've using the Events Manager plugin which creates a custom post type of 'event' and a custom taxonomy called 'event-categories'. I have the category 'courses' which has an ID of 43. I also have a ...
0
votes
1answer
391 views

Insert two row in wordpress database

Hello I am working on a template where I have to grab some value and insert them in my own created table in wordpress database. Now as I dont know how to insert record in wordpress database , so i am ...
0
votes
1answer
158 views

get data with shortcode

i have a wp db. and i added a table "wp_mapmus" now i want to show these datas on post page with shortcode. But there is an error. and i dont know php very well. i only use same plugins. what is the ...
0
votes
1answer
734 views

WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]

after wordpress update to 3.5+ i get error in this plugin. I do not understand how to fix it. If anyone can help me with these problem or give me an example of how to fix it here is the full code of ...
0
votes
1answer
473 views

Can I use wpdb to insert query results into a post?

My website currently consists of content drawn from database queries, displayed with php. Specifically, there are 4 modules, each of which queries a different database to get all records that match ...
0
votes
1answer
161 views

Delete/replace img tags in post content for auto published posts [closed]

In my blog I have set up auto-publish for posts and I get 5 thousands new posts every day, in this moment I have more than 150 thousand posts. I need a script, or a plugin, or a function to connect ...
0
votes
1answer
183 views

I'm not able to get access to $wpdb [duplicate]

I'm developing some additional functionality with a jQuery autocomplete form, some custom database tables, and PHP to query the tables. I have it working outside of the WordPress framework using ...
0
votes
1answer
35 views

query a newly created table using $wpdb

i created a new table inside my wordpress database called forms, this table consist of ID and names i want to query all the list from this table using the wordpress $wpdb this is my code below ...
0
votes
1answer
93 views

wpdb_prepare with multiple or condition

I want to execute a query like this: $wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string ); If I do the query with only one ...
0
votes
3answers
721 views

How to Modify this $wpdb query to accept an array of post statuses

I'm using this function from this accepted answer, which gets all values for a custom field key (cross-post). How could it be modified to allow an array of post statuses? function get_meta_values( ...
0
votes
1answer
636 views

Call to a member function get_row() on a non-object, Unable to use global $wbdp inside a plugin

I am building a custom plugin for my WordPress site. I made a php file called "checkrank" that obtains data from a custom table named "cranking". $uid = $GET['id']; function checkExists($id){ ...
0
votes
2answers
2k views

Getting value from database table depending on field value

I am using a plugin called formidable which is similar to Gravity Forms in terms of purpose. I have two fields of interest. The first field loads up all the values in the Town column of my ...
0
votes
1answer
67 views

WordPress Mysql query and Duplicate

i've a problem with mysql query on my wordpress database. I've custom fields Country and City. At moment I have this query that show all the cities of "UK" Country $querystr = " SELECT wposts.* ...
0
votes
2answers
124 views

$wpdb is queried but results don't show

I am trying to show a list of custom post types on a page template. When I view the page, instead of seeing the different posts, I see the actual page repeated. For example, If I have 5 posts, the ...
0
votes
1answer
53 views

select a single val though a table in wordpress

The table is like this: category_id category_name category_parent_name I would like to get category_id by using category_name. I searched online, and the code is like below: $ad_cat is the ...
0
votes
1answer
190 views

Plugin to create Posts and Forums then choose category and parent forum

I need to create a plugin for a customer that will help him create posts and forums and place them in a category and choose if it's a parent or a child forum. Just created a GitHub Repo for my files ...
0
votes
1answer
49 views

$wpdb->update Issue

Can anyone see what I have wrong here? $wpdb->update( $table, array( 'lat'=>$paper_lat, 'lon'=>$paper_lon ), array( 'id'=> $result=>id ...
0
votes
1answer
176 views

wpdb prepare sql problem

I have problem with wpdb prepare and sql query. If i run the query directly thru wpdb->get_results it's working fine. Here it is: $alabala_sql = $wpdb->prepare( " SELECT * FROM ...
0
votes
1answer
241 views

Get all sticky posts from one user through user ID

So I need to get number of sticky posts each user have and compare it to one variable. I managed to do this, but I am wondering is this the right way to do it. //Retrive all sticky posts ID ...
0
votes
1answer
99 views

WPDB Query Question with Category Only

I am trying to pull up posts from only category ID 18 with this query for a plugin I am working on but it will not work. I can not use query_posts or WP_Query in the place I am using this. global ...
0
votes
1answer
86 views

How do I query for posts by custom meta and those that have been stickied?

I realize how clumsy and inefficient this query is but SQL is not my strong point. I use the following query to pull the latest 8 events from a custom post type called Event Posts. However, I also ...
0
votes
1answer
523 views

$wpdb->insert Database Error Duplicate Entry Error Logging

Is there an equivalent to INSERT IGNORE in the wpdb class? As I'm fetching and inserting a twitter feed and the field in which I store the tweet ID is keyed UNIQUE, I am aware that duplicates are ...
0
votes
1answer
194 views

accessing wordpress serialized data outside wp

I've never worked with serialized data... I need a little help with how to load "text" widgets title and content in php script outside wordpress... my script just connects to database (including ...
0
votes
1answer
234 views

Select From wpdb - Author/User Directory page

I am working on a wordpress site where I have created a directory page(authors.php) that lists all users and certain author meta. It works fine however I am trying to figure out how to only show ...
0
votes
1answer
103 views

Help with Related Posts Function

I'm trying to write a function that will grab all related posts according to the term of a taxonomy. I'm having trouble though trying to query multiple terms. The way I am doing it right now is using ...
0
votes
2answers
2k views

How do I create a single.php for a specific category?

I am trying to create a single.php file for a specific category on my site. Instead of loading the single.php file I want WP to return that category in a file called single-category-53.php (the actual ...
0
votes
1answer
668 views

How to check for empty and not a failure

I'm querying the postmeta table to see if a url has already been entered, using this statement (where $thisLink is the url I'm checking) $mypostids = $wpdb->get_results("select * from ...
0
votes
1answer
466 views

Wordpress SQL JOIN query

Hi Im trying to run 2 querys in the same query call. // send the query global $wpdb; $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy; $comments = ...
0
votes
1answer
1k views

How to insert multiple postmeta values with one query?

I have a custom script/plugin I am using for myself that creates a post along with some postmeta information. Right now, I have multiple $wpdb->insert, but I would like to condense this down into ...
0
votes
2answers
129 views

$wpdb->prepare error after Wordpress update [duplicate]

Possible Duplicate: $wpdb->prepare() warning in WordPress 3.5 Im facing with a error after updated Wordpress to 3.5, Im aware of error but I cant fix it. This is code: ...
0
votes
1answer
653 views

Post Bulk Update

Is there any way to update all the posts at a time through query or through admin panel. For an example i am having an 1000 posts, how to update all the posts at a time. Thanks.
0
votes
2answers
196 views

Wordpress $wpdb no result

I have the following code in my functions.php $code = 'EUR'; global $wpdb; $query = 'SELECT * FROM '; $query .= $wpdb->get_blog_prefix() . 'fxbase '; $query .= 'WHERE code= '.$code; $data = ...
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 = ...
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 = ...
0
votes
1answer
709 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 ...
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
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 = ...
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 ...
0
votes
2answers
311 views

Disable (or limit) queries when certain content (or data) is not needed (or showed)

Currently I am making a custom design for a site. The problem I'm seeing in Wordpress is about almost all data pulled out from the database. While in certain pages - like front-page.php - it only ...
0
votes
1answer
190 views

get_var is neither a string, integer, or array …?

$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND company = %s", $product, $company)); ...
0
votes
1answer
778 views

PHP variables in mysql query

What is the consensus on how to insert variables in a MySQL query using the $wpdb->insert syntax: ($table, array($column=>$value),$format)? I know this hasn't worked: ...
0
votes
1answer
602 views

Query the links Database

Hi I'm trying to convert from a "example" wp_list_table that displays an array of data on the same page, to a "real life" table the pulls data from the database. I have the code setup to where I just ...
0
votes
1answer
284 views

wpdb->insert not inserting first variable

I have a strange error here. im trying to write to the wordpress db but $wpdb->insert does not write the variable first name. Can any one spot the error in this code? function ...
0
votes
2answers
2k views

Use have_posts() with array of post results retrieved by $wpdb->get_results

I don't know if I'm retarded, crazy or just plain genius or not, but I've decided to use tags as a way to link content site-wide (a big ol' many-to-many relationship website for archiving various ...
0
votes
1answer
177 views

how to translate countries output from wp database?

i have a list of countries in french stored in my database (wp_country). i use the code above to retrieve all the countries witth this ecohing echo '"' . $country['name_country'] . '",'; it outputs ...