Skip to main content

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
1 vote
2 answers
29 views

how to run tests using different db connection

I would like to run tests on a db different from the real one. So I cloned the real db into a new one and tried wpdb::select passing as second parameter a mysqli connection to test db. $mysqli = new ...
DEV SL's user avatar
  • 11
0 votes
1 answer
23 views

wp db request without refreshing the page

want to make database requests like for example "select * from wp_users" to the database without refreshing the page. I am in a wordpress plugin. Have try already a few things and seem not ...
tiago calado's user avatar
1 vote
0 answers
16 views

Illegal mix of collations using a function [closed]

I am running into a collation problem when using a function. My query is this SELECT CONCAT(PERSON.LastName,', ',PERSON.FirstName) AS 'PersonName', funcGetStandardValue(PERSON.ProgrammeId) AS ...
StripyTiger's user avatar
1 vote
0 answers
34 views

How to properly prepare a column name if passed to a stored procedure?

I've figured out that I can use %i with $wpd->prepare() to escape identifiers like column names. The thing is that the query I'm preparing is a call to a stored procedure like this. I want the end ...
Compjeuter's user avatar
-2 votes
1 answer
156 views

How does wordpress link columns from different tables without using FOREIGN KEY or JOIN?

I can't figure how Wordpress tables has been linked by not using FOREIGN KEY? I tried to understand from this information. For a custom plugin I want to recreate the terms, taxonomy and relationship ...
imagIne's user avatar
  • 83
0 votes
0 answers
25 views

$wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once

My custom code in my custom (class-based) plugin for some reason, writes the same record twice, when as you can see it's called once. This double write also happens even when I do the same type of ...
Mario's user avatar
  • 1
0 votes
0 answers
42 views

Skipping all WP functions for a cached version

I started making the following caching codes in order to create an experimental plugin that provides a solution to my own needs. add_action('wp_loaded', 'buffer_start'); add_action('shutdown', '...
G.D.i's user avatar
  • 23
1 vote
1 answer
35 views

Wordpress DB query

I want to capture some data from a WP website I'm building. The website will show a game to play for each calendar month (12 games). Players can come and play at any month of their choosing. If they ...
Sam's user avatar
  • 11
0 votes
1 answer
2k views

How to use wp-query to search for posts where post_content OR post_title OR post_name

Hi I'm using WP query in WP 6.1.1 like this: $posts_where = [ 'post_type' => 'page', 'posts_per_page' => - 1, ]; If there are search and status inputs I use those: ...
pg.'s user avatar
  • 141
0 votes
1 answer
40 views

multiple record insert creating many duplicate records

I want to loop over an array and store the records in the database. This is working but for some reason it is creating 30 odd records instead of just 4. I put this code into a very basic custom plugin ...
user8463989's user avatar
0 votes
0 answers
441 views

Wp forms wpforms()->entry->update not working on page refresh

Wp forms wpforms()->entry->update not working on page refresh , it only works when i do some change in wordpress dashboard (like clearing cache or updating any post) then only it is updating the ...
Ajay 's user avatar
0 votes
1 answer
227 views

WPDB query suddenly not working

I have a function that contains a wpdb query. It's supposed to get the image alt text, based on the url of the image. This is the function: // retrieves the attachment alt from the file URL function ...
Jillian Hoenig's user avatar
0 votes
2 answers
243 views

How can I update a value of a field depending on outside source?

Say I have a text file or JSON file elsewhere on my domain, that have a simple value, like "yes" or "no". I would like to update a custom field in a database table in Wordpress (...
Malachi's user avatar
  • 101
0 votes
1 answer
37 views

Is there another way to retrieve a post_id from post_meta other than a SQL query?

I'd like to retrieve the post_id from wp_post_meta with a unique meta_key and meta_value. I've tried WP_Query but no values are returned and I'm unable to retrieve the post_id' $post_query = new ...
Ryan's user avatar
  • 53
1 vote
0 answers
55 views

SQL - How to echo out <div></div> inside of where statement

In my query, is it possible to echo out a php value? If not, is there any way just to pass in the value of the id player_id? <?php $New = '<p id="player_id"></p>'; // This ...
John Lyons's user avatar
0 votes
0 answers
30 views

Putting form result in my database

i have a problem with my wordpress rn. I did a form in html and js, and i want to put the actual result in my database where i created a table for it. So basically i did a plugin in simple php that ...
Louis-Emmanuel Metan's user avatar
0 votes
0 answers
31 views

Uploading to Wordpress Database

Hope everyone is doing great. I have a small issue with uploading information to the wordpress database. I created a new table without the prefix. I created code based on what I've learned in ...
Rookie Recruits's user avatar
0 votes
1 answer
44 views

$wpdb:insert, more arguements in $format array than in $data

I'm making some customizations for a website, and I cam across this piece of code of a theme: $wpdb->insert( $table_name, array( 'user_id' ...
Faye D.'s user avatar
  • 126
0 votes
0 answers
112 views

Warning: Undefined property: wpdb::$question_overview in C:\Wamp.NET\sites\proxyvragenmodule\wordpress\wp-includes\class-wpdb.php

My question on stackoverflow was asked on the wrong part of my code I have an error that ive been dealing with since forever.. Im making a question viewer in wordpress and it shows this error Warning: ...
Shady Morsi's user avatar
0 votes
2 answers
417 views

WP_Query post_tilte search in posts table

Here is my array which I am trying to get "apple" keyword in post table but it can't work like I want. Please let me know what is wrong with my array? Array ( [paged] => 1 [...
Vipul Jethva's user avatar
0 votes
0 answers
32 views

wpdb->prepare creates random string for % character [duplicate]

I have a query like this, $query = "... user LIKE '%-guest-%' ..."; And when I implemented wpdb->prepare in my query, % characters replaced by random strings. I found solution to ...
doraemon's user avatar
  • 223
4 votes
2 answers
1k views

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 ...
Asmat Ali's user avatar
  • 139
0 votes
0 answers
28 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 '...
Shady Morsi's user avatar
0 votes
1 answer
555 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 ...
Shady Morsi's user avatar
0 votes
2 answers
61 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 ...
user228625's user avatar
1 vote
0 answers
66 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 ...
TTT2's user avatar
  • 129
0 votes
1 answer
81 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 ...
Freddy's user avatar
  • 147
0 votes
1 answer
1k 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 ...
Freddy's user avatar
  • 147
0 votes
0 answers
28 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 - ...
Freddy's user avatar
  • 147
0 votes
1 answer
129 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. ...
Freddy's user avatar
  • 147
0 votes
1 answer
104 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: ...
Freddy's user avatar
  • 147
0 votes
0 answers
73 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 ...
clayRay's user avatar
  • 135
1 vote
1 answer
235 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....
neoswf's user avatar
  • 125
0 votes
1 answer
109 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; $...
John Lyons's user avatar
0 votes
0 answers
62 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 ...
John Lyons's user avatar
0 votes
1 answer
304 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 ...
John Lyons's user avatar
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 ...
Mich___'s user avatar
0 votes
0 answers
141 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:...
user19103974's user avatar
0 votes
0 answers
157 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-...
mjones's user avatar
  • 153
0 votes
1 answer
251 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 ...
Công Tử Huyết's user avatar
0 votes
1 answer
208 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 ...
Cynthia A Lockley's user avatar
0 votes
0 answers
62 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 ...
Divjot Singh's user avatar
1 vote
0 answers
22 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 ...
Philipp's user avatar
  • 11
0 votes
1 answer
36 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 ...
Jawequo's user avatar
0 votes
1 answer
201 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 ...
Felipe Lenin's user avatar
0 votes
1 answer
94 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 ...
Steve's user avatar
  • 297
0 votes
1 answer
149 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 ...
imagIne's user avatar
  • 83
2 votes
1 answer
931 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 = "...
Artem's user avatar
  • 305
0 votes
0 answers
22 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 ...
Morty_Smith's user avatar
0 votes
2 answers
71 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 = ...
Morty_Smith's user avatar

1
2 3 4 5
25