Questions tagged [wpdb]
The wpdb class, accessed via the $wpdb global variable, is used to interact with the WordPress database
1,208
questions
1
vote
0
answers
37
views
+50
How to create a fully functional user registration in WordPress?
I used many user signup plugins for users registration and they did good job, but the problem is, each website collects different data through user registration forms. In my case, the data collected ...
0
votes
0
answers
18
views
How to check record is exist or not in WordPress CRUD Operation with $wpdb
I have been trying to custom CRUD Operation for in Wordpress Page Template, Where i need to handle CRUD Operation but I need to I need to check whether record is exist or not before Insertion.
Here is ...
0
votes
0
answers
20
views
Table wont load into WPDB
Hi im trying to add a table into my WPDB and its still redirecting to an older table (that i have deleted) despite me using the same name it shows this error
WordPress database error: [Table '...
0
votes
1
answer
24
views
I have an error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
Hello im new to WPDB and this is my error
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use ...
0
votes
2
answers
22
views
inner-wrap div pushing custom table far down on page
I am working with code in a custom child-theme. My goal is to pull data from the wpdb and display it as a custom table.
I have created and populated the custom wpdb table with the relevant data, and I ...
1
vote
0
answers
21
views
use wpdb object on other file
I need to connect my wordpress site to another database that is stored on a VPS, I also want to use this connection to query data and show it on my wordpress site, I see that I can connect to the ...
0
votes
1
answer
25
views
Get count of rows based if column exists in two different tables [closed]
I have two custom tables which both contain a column called reference.
wp_invites
id
lead_name
reference
1
John
fRgOeRkFeHIm
2
Alex
WtRA7T7NFdYW
3
Jason
IGr0ZhaCbojD
wp_rsvp
id
accepted
...
0
votes
0
answers
11
views
$wpdb how to make a record lookup
I have made a lookup form, where 2 inputted values, Selecting a Class, and Date, are prompted. Once the values are selected, then the First and Last names matching the records will be displayed.
I ...
0
votes
1
answer
40
views
How to redirect to a page after submitting form data?
I have a custom form which posts data to wpdb.
Currently, after form submit, my form keeps the user on the same page, but I'd like to redirect them to a thank you page.
Here is how the form is set up ...
0
votes
0
answers
24
views
How to get data (not value or name) from radio options to POST to database
I have a set of options that are generated based on database count. For example, if a group has 4 members, 4 radio option pairs of yes and no will show:
Name 1
- Attending? Yes / No
Name 2
- ...
0
votes
1
answer
26
views
Can't send form data to wpdb when URL has query string
I have a table called wp_invites which contains a list of invitees. This table contains a column called reference, which is added to the URL as a query param in order to customise their invite (i.e. ...
0
votes
1
answer
26
views
query_vars doesn't return query string (trying to get data from $wpdb)
I have a ref query string which matches rows in my wp_invites table.
In my wp_invites table, I have the following columns:
lead_name
reference
Let's assume here is one of the rows:
Lead name: ...
0
votes
0
answers
16
views
Error resetting database index using ALTER TABLE in $wpdb->query
I'm running a Cron job every hour that clears all posts of a particular CPT and then re-inserts data by accessing a third party API.
I'm worried that this will lead to huge indexes, so I would like to ...
1
vote
1
answer
44
views
get_post_meta bringing back results, but $wpdb->postmeta doesn't
I'm trying to discover if post exists, based on post_title & metadata post_language.
Until now, the best way I discovered, was using methods appearing in posts like this one, this one, or this one....
0
votes
0
answers
15
views
posts_clauses drop ACF get_field function
I try to use function for order by stock status but this code drop ACF get_field() function
when function on, get_field return only ID of post
and when function off, all right, get_field return array
...
0
votes
0
answers
8
views
Translating wordpress foreach to ajax
Im having difficulty translating a foreach loop in wordpress to ajax.
The foreach loop in wordpress (working correctly):
$query = $wpdb->get_results("SELECT first_name, last_name FROM ...
0
votes
1
answer
27
views
Wordpress Ajax - looping data into a table
Can anyone tell me what I did wrong? I made an ajax call in wordpress to loop through data to display the results on a table.
Here is my php:
function DisplayInfo() {
global $wpdb;
$...
0
votes
0
answers
13
views
How to display inputted data in Ajax without button or click event
I am working with wordpress and using ajax to try and implement some input fields that upon submission show the results below. Is there a way in which one can display new entries submitted by the user ...
0
votes
0
answers
15
views
Wordpress Query -> Ajax Query
I am trying to display all of my data onto wordpress via AJAX, and not regular Wordpress. I can display the data on the page, but in order to see if new entries are made, the page needs to be ...
0
votes
0
answers
18
views
how to display tables via ajax
I made an input form with ajax that successfully sends data to the database without the page reloading. I displayed all the data in a table below. However, if a user wants to see their recent entries, ...
0
votes
0
answers
22
views
$wpdb Ajax not redirecting to main page
I'm having difficulty with redirecting a page once a person submits data. I made a form, and when the user clicks 'Add student', the data would be encoded through json, stored in the database. The ...
0
votes
1
answer
63
views
Changing regular db connection to $wpdb
I am working on a wordpress site, and started implanting a CRUD database. I coded out an example that works perfectly on my localhost. However, I am working with file mangaer in cpanel, and am having ...
0
votes
0
answers
13
views
Site uses wpdb to fetch meta_keys but just displays first meta_key from a page (the post uses the same meta_key "filmmaker" more than once)
My page should display all filmmakers, that have been tagged as "filmmaker" in my posts. I do have posts that feature more than one filmmaker (meta_key = filmmaker) in custom fields, but ...
0
votes
0
answers
29
views
$wpdb The query does not contain the correct number of placeholders
I am trying to push some data to a custom table in my Wordpress install, but I am getting the error The query does not contain the correct number of placeholders and I'm not sure why. Here is my query:...
0
votes
0
answers
15
views
WP Recommended Table Exclusions?
I just re-designed my WP work flow to utilize 2 bash scripts (push.sh & pull.sh) that I wrote that will push/pull my files with git, upload/download & import/export my dbs using rsync and wp-...
0
votes
1
answer
36
views
update $wpdb one query
Is there a way to change mysql directly in wordpress just 1 operation without needing 2 operations: query and update?
I am facing problem of multiple concurrent transactions impacting point_user
I ...
0
votes
1
answer
37
views
How do I change the datetime format from ( 'y-m-d' ) to ( 'd m y' ) [closed]
I have code that finds the date a page was last updated:
<?php global $wpdb; $psm_mod_datetime = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_title = 'Current ...
0
votes
0
answers
31
views
Wordpress ajax response save into database
I have this code which grab playlist from youtube and through foreach and ajax send data to wordpress function to save into database. IT is not working, i know somewhere i'm doing wrong but unable to ...
0
votes
0
answers
34
views
Need help creating asynchronous data scraper in WordPress
I need some help on a data scraping script I've been working on. I want to create a script through which content can be extracted from a page.
I fetched the page via wp_remote_get() and ...
0
votes
0
answers
10
views
How do I have a user upload a blog post and then retrieve that to display in a card on the site?
Hello everyone, this is my first time on a forum like this so please be gentle! I will try asking and answering as accurate as I can.
I have to create a site in which you can send in some data using a ...
1
vote
0
answers
15
views
Output: "Array" [closed]
I added a table in the database which collects names through a form.
I want to output the latest entered name on a different page than the one which contains the form.
In order to print the data I ...
0
votes
1
answer
23
views
Display current ranking of post as a number in post title
I have a page where people can rank stuff. My posts are ordered by the current ranking which is stored as a meta key in post meta.
Now i want to add the current ranking spot within the title of the ...
0
votes
1
answer
67
views
Trash Bin for Categories?
I have a cat_notice taxonomy, where there are several categories and one of them the slug is 'trash'. In this case I created a link and I needed that when I clicked on this link I would take the ...
0
votes
1
answer
34
views
Is it important to have integers inserted using %d rather than %s?
Is it important to have integers inserted using %d rather than %s?
I have a situation where there is a large number of fields and values. When database changes are made, it is difficult to match all ...
0
votes
1
answer
33
views
check that the data exists before sending it to wpdb
When I send data to wpdb from form I can have some empty fields.
How can I add conditions to array of data inside array or before insert wpdb to send only filled fields ?
The fields concerned (for ...
0
votes
0
answers
95
views
MySQL Query Returns Array () In Shortcode
This is in my theme's functions.php. I have an external MySQL database that I'm connecting to in WordPress with the following code, and I'm attempting to create a shortcode that shows the total of a ...
2
votes
1
answer
268
views
$wpdb->get_results(...) with $wpdb->prepare(...) returns empty array despite correct query
My MySQL query is correct, but $wpdb->get_results(...) produces an empty array. Here's my code:
$key = 'user-input-key';
$value = 'user-input-value';
$value = '%' . $value . '%';
$query = "...
0
votes
0
answers
16
views
How to save template data into wp_post table (post_content column)
Is there a way to save template data into wp_post table?
I made a custom template that automatically makes tables and some sentences with the meta-data that users insert in.
I wanted to make users ...
0
votes
0
answers
96
views
WordPress get last inserted user id
I want to disable user_login field into my CMS. They are register only their email adress. I think to create secret user login by programmatically. I think for accessibility and manageability also I ...
0
votes
2
answers
35
views
Cannot get wpdb data (Error in a simple fuction) [closed]
I'm using Cryto Plugin and want to get coin price data from plugin db.
For easy practice, I'm trying to get BTC data.
<?php function get_coin_price($coin_symbol) {
global $wpdb;
$coin_price = ...
0
votes
0
answers
57
views
Can't find out why dbDelta dosen't create my table
I have a function which needs to create a new table an d i can't see for the life of me why it dosen't create the table:
function afdv_create_delivery_table ( $id ){
global $wpdb;
$...
0
votes
0
answers
101
views
Add posts to custom table in database instead of wp_posts
What the code does:
Imports posts, loops through all the posts and calls wp_insert_post to create a new posts for each import.
Objective:
Import posts and store them in another table, not under the ...
0
votes
1
answer
208
views
how to get serialized post meta
I have posts that have video content and these videos stored in database like this (serialized) a:1:{s:9:"video_url";s:0:"";}
This serialized data have post video urls but can ...
1
vote
2
answers
892
views
wpdb get_results() and prepare when to use prepare?
so if i have a function that gets terms from the database ( not the user ) do I need to use prepare first ( before get_results() ), or some sort of data sanitizing?
0
votes
1
answer
397
views
How to left join meta in queries [closed]
I have a query something like
//read products with thumbnail and sku
SELECT products.*, pm1.meta_value as sku, p1.guid as thumbnail
FROM `wp_posts` as products
LEFT JOIN `wp_postmeta` as pm1 ...
0
votes
1
answer
41
views
Isn't Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
I'm trying to count rows in sql table using SELECT COUNT(*) for the post view count. My code is
function get_post_views($offset=0, $post_id){
global $wpdb;
$get_visit_query = "...
0
votes
0
answers
98
views
wordpress mysql / wpdb ajax load more for terms help
Can anyone pls assist me with my problem. I am not asking for code, but even some guidance as to how to get this working. I have tried many ways, to get my terms to load using ajax load more and seem ...
0
votes
0
answers
190
views
Get child product categories from parent product category for CUSTOM TAXONOMY archive page
Can anyone help me as LoizTheAztec pretty much covered most of what I need here with his very helpful answers. What I need to do is alter this further, and rather than it being on a Product Cat ...
0
votes
0
answers
71
views
Improve performance of slow query
I'm using this query to obtain all the products buyed by user and works but query monitor says me that is a slow query (above 0,5 sec), there is a way to fix this?
Here the db query:
$result = $wpdb-&...
0
votes
1
answer
40
views
Sql formatting for post data within function
I'm calling a function through ajax in my site, and within the function that's being hit I'm taking the data (in this case it's a search term) and putting it into LIKE statements in sql:
$...