Questions tagged [wpdb]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
14 views

How to get specific attribute from DB

a:3:{ i:0;a:2:{s:21:"wwsd_percent_discount";s:2:"10";s:25:"wwsd_minimum_discount_qrt";s:2:"20";} i:1;a:2:{s:21:"wwsd_percent_discount";s:2:"20";s:25:"wwsd_minimum_discount_qrt";s:2:"50";} i:2;a:...
0
votes
0answers
29 views

How to add virtual column in wpdb get_result statement

i want to add a virtual column to wpdb get_results statementthis is my code and the column gid returns nothing . $result = $wpdb->get_results ( " SELECT helo AS gid, calendar_id, day FROM table1" )...
0
votes
1answer
12 views

Using id to show item

Im working on a project where i upload a gpx file and use the path of gpx to put in a shortcode plugin i use the post id the get a filled in shortcode i use this code to get me the piece of info for ...
0
votes
1answer
19 views

Custom array from a query only write the last row of the query

Looking for some input on this one. I am writing a custom array but having a strange issue. It seems to be cycling through the loop and dropping previous values and only storing the last row of the ...
0
votes
1answer
27 views

WordPress Query doesn't return the correct value

According to this page: Return #Return (int|bool) Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error. ...
0
votes
0answers
19 views

How to write the backend for a simple single page application

I want to write a small app on a particular wordpress page which should have following basic functions: After choosing an item in a drop-down menu, get respective information via a GET request (AJAX?)...
1
vote
0answers
30 views

Change commission_status paid when withdraw_status vendor is completed

I need to change commission_status paid automatically after changing commission_status paid when the withdraw_status vendor equals "completed," not check mark. action:$actions = '<a class="...
1
vote
0answers
21 views

Intermittent database errors when accessing WordPress database

Update: I've narrowed this down to a couple of issues that seem unrelated. The testing suite was disconnecting my database without reconnecting. (resolved) The mysqli_free_result(): Couldn't fetch ...
0
votes
0answers
28 views

update_post_meta not working in template_redirect action

I have a problem I'm trying to listen to a webhook, and I can do it, I check with the help wp_mail function and I get all the data But I want to make a add data in the database, and for some reason ...
0
votes
0answers
28 views

$wpdb->get_results returns different results compared to phpmyadmin

this is my sql statement, which works in phpmyadmin: SELECT wp_ccs_cashflowaccounttype.cashflowaccounttypeid, wp_ccs_cashflowbookingtexttype.cashflowbookingtexttypeid, w.invoiceid, ...
0
votes
1answer
19 views

Basic wpdb update question

I can't get this to work and I don't really know how to debug it. In the URL I'm getting this added: ?candidat=41&selectCandidate=selectCandidate global $wpdb; if(isset($_POST['...
-1
votes
1answer
28 views

how to use transient method?

It was suggested to use a transient method to remove the duplicate queries Duplicate Queries Why does this don't work? Is it the wrong way to use it private function get_acf_list() { if(!...
0
votes
1answer
18 views

Custom Query returns array, but I can't see it's elements

guys! I have the following problem to solve - I am using Private Content plugin which divides users into categories. I need to show all posts from the category that the author is part of. I tried ...
0
votes
0answers
10 views

Creating a table from another's results using WP $wpdb functions

Below is the query and function I use to create a table from another table's results: $mytable = "myCustomTable"; $thisSQL = "SELECT p.ID, p.post_title, p.post_author, p.post_status, COALESCE( ( ...
0
votes
1answer
30 views

Get records from Formidable Table using $wpdb->get_col

I am using Formidable Pro as a CRM and one form has a field called cust_id. Now I want to get all the records stored within that form with a specific cust_id. I did: $form_id = 7; $search_id = 300; ...
0
votes
1answer
41 views

Querying specific table row by current user login

I m creating a user based website in Wordpress, where each users can create an account and upload data of their records into the website. But I m having trouble thinking of how users can view a ...
0
votes
0answers
20 views

$wpdb->insert duplicating rows

I'm using $wpdb->insert to insert data into a custom table on my wordpress database. Unfortunately, it is inserting the data multiple times. I have searched through other topics posted, and haven't ...
0
votes
1answer
37 views

Wordpress “wpdb->update” - Append Text Value

I am trying to update a table column by appending some text to the existing value in the column. Basically, I am trying to do something like this: $wpdb->update('table_name', ...
0
votes
1answer
16 views

Prepare WPDB with meta key and meta value

I'm trying to prepare WPDB by post type, meta key, and meta value global $post; global $wpdb; $rid = absint($_POST["rid"]); // number $last_id = absint($_POST["lastID"]); // post ID $query = $wpdb-&...
0
votes
0answers
13 views

Applying pre-production modifications

I'm working on a wordpress website on a pre-production version that includes several extensions like woocommerce and others. I'm wondering what is a safe solution to apply all the modifications I made ...
0
votes
0answers
35 views

wpdb insert into point column in db

I am struggling to insert a combination of lat and lng into a point column in my database. I am trying the following, but i always get an error "cannot get geometry object from data you send to the ...
0
votes
2answers
30 views

$wpbd->insert() does not insert user data

I am having trouble inserting logged-in user data, using the 'user_register' hook. The following code inserts a row in the database, but only inserts the 'email' column. function nuevoPostulante() ...
0
votes
1answer
28 views

Looping through custom data in a custom table to display all items in a post

Im trying to loop through my custom data in a table to display on the page. Everything is working as intended except the posting to a page using the wp_update_post() function. Here is my function: ...
-2
votes
1answer
35 views

Create a Wordpress Database query to find users who purchased specific product through WooCommerce [closed]

I am working with a company that provides online content in the form of semesters you pay to access. The semester is set up like a product that you purchase through WooCommerce. We've been applying a ...
0
votes
1answer
69 views

I want to get term by term_name without taxonomy

Can I get the term by it's id without knowing to which taxonomy it belongs? I have a meta field that stores term names, but doesn't store the taxonomy. However, all the get_term() function have ...
0
votes
2answers
34 views

WPDB SQL query SELECT from category

I wrote SQL query to get items ID with 'instock' status, but don't know how to add to SELECT only from specified product category. My code: $results = $wpdb->get_col( " SELECT p.ID FROM {$...
0
votes
0answers
35 views

Get All Custom Field Values from a Specific Category and Store Them in an Array

I added a custom field (location) for some posts. I want to get all the locations from posts from a specific category and store them in an array. I am using the following code to get all the values: $...
0
votes
0answers
92 views

Not getting ajax success response on insert/update row to database

I am not getting success response after inserting/updating record to the database. Instead ajax returning error: function(response) with Something went wrong! message. $this->gs_db is the ...
0
votes
0answers
16 views

How to rerieve comments and their replies from DB

I need to get comments and their replies from database to show them as json for an android app, so how can i tell if a comment has replies (get their number ) , and how can i list replies nested with ...
0
votes
0answers
28 views

How to get user avatar via WPDB

For my REST-API i need to get for every post the username, date ... and Avatar ! $query ="SELECT POST.ID, POST.post_title, POST.post_date, USER.user_nicename FROM wp0x_posts POST INNER JOIN ...
0
votes
2answers
567 views

Get WooCommerce product attribute taxonomies in a SQL query on WordPress database

I am trying to retrieve a list of all my attributes_name values (carat, color, size etc) from the WooCommerce table wp_woocommerce_attribute_taxonomies in WordPress database. And here is my code ...
0
votes
1answer
17 views

$wpdb->prepare with LIKE returning blank array instead of rows

I trying to select data from a table using LIKE and wildcards. I tried basically everything. Here'is the last code according to WordPress documentation: <?php global $wpdb; $table_name = $wpdb-&...
1
vote
1answer
18 views

When to call add_filter

I am using wp_video_shortcode_override filter in one of my plugins. I would like to make this as on option top user so its not active by default. I have set up following scenario. I need to call wpdb ...
0
votes
1answer
30 views

Why $wpdb->insert and $wpdb->update not working server but it is working in localhost?

I am working in a wordpress site, I started to work in local enviroment using xampp server. I used wpdb to do operations with the database like this: global $wpdb; $name = $wpdb->get_results(...
0
votes
1answer
36 views

How to get row value from wpdb

I want to echo 'yes' if the "notification" row value is 1 I tried to do with this code: global $wpdb; $row =$wpdb->get_results("SELECT * FROM wp_users"); if($row['notification'] == 1){ ...
2
votes
2answers
120 views

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

I have this code: $query = "SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ...
0
votes
1answer
103 views

Displaying SQL query result from user input via wpdb

I'm a bit stuck with one of my task which is to require a user input for an 'ID no' and it shall go through a table in my WP and display the result on the same page (after hitting Submit). I'm ...
0
votes
0answers
13 views

WP SQL sintax to filter by multiple criteria

Ciao guys, I am trying to get products by an $wpdb->get_col() SQL query, but I am in trouble with the SQL syntax. I need products which have an exact category and IN at least one taxonomy terms. ...
0
votes
0answers
21 views

Inserts of Custom Fields to postmeta are not persisting

I have a script which, after creating a post, inserts a number of rows into wp_postmeta for the just-created post. The rows are inserted, and opening the post for editing shows these values where I ...
0
votes
2answers
626 views

Connecting to external oracle database

So I'm trying to connect to an external db in order to access/update information located on a different non-wordpress database (oracle). I tried constructing a new wpdb object (as suggested by many ...
-1
votes
1answer
17 views

query using wpdb in wordpress gets me no result

I get no result unless i cut the string title to "Gocomma 10W QI Wireless Fast Charger Car Mount Holder " ... $title1="Gocomma 10W QI Wireless Fast Charger Car Mount Holder - 2pcs (it)"; $...
-1
votes
1answer
33 views

$wpdb->get_var returns 0

I use following code to get a number : $where = 'WHERE type = 4 AND active = 1 AND user_id = ' . $user_id ; $user_followed = $wpdb->get_var("SELECT COUNT( * ) AS total FROM {$wpdb->tablex} {$...
0
votes
1answer
19 views

Get table parameter and save in meta value

I want to get number_1 and number_2 and save in meta_value in table wp_postmeta. How do I do the same? The id_help_i and the same of the $post-> ID. Some id of the table wp_table_help_i does not ...
0
votes
0answers
18 views

SQL query that returns a list of duplicate posts IDs, comparing their post_parent and a post meta value?

I want to build a SQL query that would fetch all the duplicate posts; by comparing their post_parent and the 'link_url' post meta. ID | post_parent | link_url meta 1 11 ...
0
votes
2answers
36 views

Can I use a wpdb object to connect to a non-Wordpress Oracle database [duplicate]

I simply have a quick question. I've found information related to this, but I'm not completely sure if this is possible. I know that I can create a second database connection using the wpdb object as ...
1
vote
0answers
44 views

Return terms from multiple taxonomies using $wpdb

I would be the first to admit that I know next to nothing about SQL queries, but after numerous searches and some trial and error I was able to cobble together a query that returned the results I was ...
0
votes
1answer
16 views

How do I create a WP endpoint that retrieves all custom post types that have a tag?

I have a custom post type, let's call it 'capability'. Each capability can have one or more tags. I have a searchbox on the frontend that the user can type into to search for all capabilities that ...
0
votes
1answer
28 views

$wpdb->insert inserting only f character in custom table

I have made a quick $wpdb->insert function that adds content with an AJAX function. The goal is to insert the form data into a table. Here is my Javascript function calling the ajax: $("....
0
votes
0answers
31 views

Modify post image in full size

I have a website where the client attached many “full size” images to posts, most of them in 5000px width, is it possible to run something for resizing those images to large? Instead of going through ...
1
vote
3answers
129 views

$wpdb -> Batch insert from XML File?

Actually im stuck on this! XML-File ~ 140.000 Rows Filesize ~ 9.0 MB LOAD XML INFILE 'file_name' isnt't allowed ( shared hosting! ) The supplier provides a single XML file with quantity and sku. The ...