Questions tagged [sql]

SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Filter PHPMyAdmin table with search bar [closed]

I made a table in the PHPMyAdmin that I have in my WordPress dashboard. Picture: I'm trying to make a search bar to sort the table by internship name, but it's not working. Picture: Here's the code ...
0
votes
0answers
47 views

How to query more than one meta key and value with SQL

I am trying to add a second condition to my SQL where I select from a specific role and another meta key. It works fine with just the role condition but when I try to add the second one it doesn't ...
0
votes
0answers
35 views

DB prefix not updating

I have a site I built locally and migrated to a live environment. Later I created a copy of this site and booted it up locally again to do some further dev in there. My local dev software (Local by ...
0
votes
1answer
35 views

Trying to create a shortcode to display categories with a specific product tag

I currently have the following and it is not working: If I put the shortcode [tagtagtag=246] i get an array to string error function get_categories_with_product_in_tag( $atts ) { $atts = ...
0
votes
1answer
24 views

SELECT custom post type and its meta in SQL

So I have the following SQL script where I can view all my post_meta with specific meta_keys: SELECT * FROM `wp_postmeta` WHERE `meta_key` = 'honorific' OR `meta_key` = 'suffix' OR `meta_key` = '...
0
votes
0answers
20 views

SQL DELETE multiple post_meta on single and multi-sites

So I don't have too much knowledge on SQL and running scripts, so I wanted to see if the community can help me. Here is what I'm attempting to do: Delete all post_meta that has the meta_keys honorific,...
2
votes
0answers
26 views

Bulk-create posts from SQL database

I'm new in this forum and fairly new to Wordpress as a whole, so I hope I will abide by all written and unwritten rules when posting this. I have an SQL database with around 4,000 posts from an old ...
0
votes
1answer
16 views

WP_Query() not working as expected

I'm building a plugin for EDD which adds a custom metabox with checkbox option meta_key _xy_global_product. So far, so good. In the frontend, I'm trying to filter posts which have this meta_key set to ...
0
votes
0answers
34 views

Deleting empty meta key values

Is it safe to use DELETE FROM wp_postmeta WHERE `meta_value` = '' in SQL in order to remove meta keys with empty values? Could any errors or problems occur?
0
votes
0answers
18 views

Fetch Data from an external MSSQL Database in a Managed WP hosting

SO, my client is using a managed WP hosting, which is why I can't install MSSQL drivers in his server. I am building a plugin for him to fetch some data from their office's MSSQL server. Now, I have ...
0
votes
1answer
31 views

How I can change the condition or compare operator for WP_Query in pre_get_posts

So here is my problem I want to show Posts if have same category if not have post then show post of same tag. And to do that I am using "pre_get_posts" action. and setting query like ...
1
vote
1answer
27 views

Search and Replace in database: How to replace data in SQL dump file [closed]

I need to help about the snr procedure provided by Courd Headman in the following thread : Search and Replace in database: How to replace data in SQL dump file on Windows? I am getting following ...
0
votes
2answers
35 views

Increment integer field in database when WHERE needs to be dynamic [closed]

I have a database column called "upvotes". I have another column called "userid". I would like to increment the value in the "updates" column where the userid matches the ...
0
votes
2answers
45 views

Do I need to sanitize $_POST['keyword'] before send to 's' parameter?

Anyone know how to sanitize the $_POST for wordpress? $args = array( 's' => esc_attr( $_POST['keyword'] ), );
0
votes
0answers
27 views

Cannot get sql request from Query object?

$qry = new WP_Query(array( 'post_type' => $this->type, 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => "_{$this->metaPrefix}...
0
votes
1answer
16 views

add products to WordPress site automatically

i have a products sql database table from none WordPress old site with names description and category fields but the category has only id from category table and i have to move all these products and ...
0
votes
0answers
37 views

How to get image path from id using SQL

I want to use a SQL query to get some random users and display an advanced custom fields profile image. Currently with this query I get the image ID back but I somehow from that need to get the url ...
0
votes
0answers
20 views

How to query results for post_title and Custom Post Type/ACF field pivot query

I have a custom query that needs to match a search term to a custom post type of event by post title and by an ACF field host and then filters out events that have passed the current date to a REST ...
0
votes
1answer
13 views

I want to get on those users their meta value are like “AGENT” .. but this query is not working

SELECT display_name FROM $wpdb->users WHERE id IN (SELECT user_id from $wpdb->usermeta where meta_value LIKE '%agent%')
0
votes
0answers
12 views

Taxonomy list inside the query

Is it possible to get a list of the "terms of taxonomy" or "just used taxonomy types" defined within that archive without looking at all pages of an archive query in a loop? What I ...
0
votes
0answers
19 views

Customising the default wordpress search functionality

I find the current from WordPress too strict as it doesn't allow for some minor spelling mistakes. How can I edit this function? I was checking out pre-get-posts however I don't think that allows me ...
1
vote
0answers
17 views

Editing the default wordpress search

My wordpress sites search function is not relaxed enough for my liking. I want it to match more items and be less strict. How would i do this? I was thinking it would to do a pre-get posts filter but ...
1
vote
2answers
27 views

Difficulty importing my live site to local

Im using local by flywheel, Here are the steps i have taken so far: Installed local by flywheel and created a site called stage Downloaded the website from CPanel and also the SQL database Imported ...
0
votes
1answer
89 views

wpdb->get_row is selecting the variable as a column name

I'm using wpdb to get a row of a table $file = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}vip_files WHERE {$file_hash} = `hashcode`&...
0
votes
1answer
19 views

Run a sql (update) after 12 hours after the user login. Woocommerce users

How can I Run a sql (update) after 12 hours after the user login (for Woocommerce users) After 12 hours after a user login, I want to run a sql/ function to update a value in the database. To set a ...
0
votes
2answers
53 views

Display data from phpMyAdmin with WordPress

I have imported my website to Wordpress and facing a big issue how can I do sql Query to display data on my pages with wordpress? for example I have product, price, description which I need to display ...
0
votes
0answers
33 views

How delete post_content records of specific category from phpmyadmin

I need a SQL command to delete post_content records for specific category's posts
0
votes
1answer
53 views

SQL Bulk update all Wordpress user's nicknames to firstname + lastname format

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead. I've put together this code ...
0
votes
0answers
38 views

Sql query to get all metadata for a post

I have three tables in my database one is users table the other is posts and wp_post meta. In the user table I have all the user details . In the wp_posts table I have different posts types . I want ...
0
votes
1answer
32 views

How to get database connection details without longing to cpanel in WordPress?

I am creating a WordPress plugin and in my plugin i need to do some SQL statements ,in the site i am working on i have access to WP-admin but i cant get to the files to get database name and password ...
0
votes
2answers
20 views

Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?

With a default Wordpress install, with no plugin installed, does the read-only visiting of the website generates write operations in the database? By read-only, I mean: visitors come and don't post ...
1
vote
2answers
54 views

Syntax for $wpdb->prepare when searching in two columns

I have this working statement for searching a single column in my database: $foods = $wpdb->get_results( $wpdb->prepare( "SELECT id, foodname, namevariations, calories, carbs, fat, protein, ...
0
votes
0answers
36 views

Creating multiple tables with Plugin

I opened a new question, just to be sure. The former request has partly been resolved. I got another question regarding creating tables for wordpress: Only one table is created (The first one), but ...
1
vote
1answer
39 views

Problem with creating tables for Plugin

I hope someone can help me. I try to execute this code to install the tables for my Plugin. But for some reason it doesn't work (Doesn't appear in my wordpress database) and I can't find out why. Can ...
2
votes
1answer
84 views

how to execute different sql query in non-sanitized $wpdb->get_results function

I saw $wpdb->get_results that function is not sanitized by core code($wpdb is get_results escaped). For example, in following code $wpdb->get_results( "DELETE FROM `wp_postmeta` WHERE `...
0
votes
1answer
46 views

Using AND and bracket grouping in SQL not working

I am trying to combine two conditions in a query but it isn't working. but running the conditions independently works. LEt me explain. When I run this query: SELECT DISTINCT SQL_CALC_FOUND_ROWS ...
1
vote
1answer
45 views

Wordpress SQL Injections through User Agent

Currently Wordpress seems to be scoring bad on SQL Injection through User Agent. The testing tools that are being used return that it's insecure because it returns HTTP responses (errors) when you ...
1
vote
0answers
12 views

Needing to move content from postmeta to posts in sql [closed]

I have conent located in a custom field named main_content in wp_postmeta and need to copy that content to post_content in wp_posts. There are about 400 posts and have no sql background but should be ...
0
votes
0answers
35 views

Removing Malware

I've been asked to remove some Malware from a friend's site. I've found some wonky links in the wp_postmeta table, but the post_id that the field is associated with doesn't exist - and, weirdly, it's ...
0
votes
1answer
48 views

Use $wpdb or other PHP script method to find/replace in WP database

I'm hoping to push a bug fix for a custom WordPress plugin my sites use. The plugin registers a shortcode with various attributes. However, there's a bug where one of the attributes is incorrectly ...
1
vote
1answer
37 views

WP_POSTMETA changes site crash

I try to update wp_postmeta from SQL script. This is my original row in table: a:7:{s:16:"lambda_page_item";a:24:{i:0;a:9:{s:9:"grid_size";s:3:"940";s:7:"boxname&...
0
votes
1answer
124 views

SQL to set Display Name to First Name + Last Name

I'm trying to set the wp_users.display_name for a rather larger users db using SQL query. Got till this point: SELECT x.display_name, x.first_name, x.last_name FROM (SELECT u.display_name, f....
0
votes
0answers
13 views

WP Query - grouping posts by same meta key, adding together values from another key

I'm attempting to create a leaderboard for 8 teams that will play multiple games and earn different amount of points for each game. The setup will be pulling entries from a custom post type game, ...
0
votes
0answers
14 views

Custom User registration system

before asking this question I have been checking out other questions but still could find an answer. Please don't mind if I ask a silly question. The situation: I would like to build a user ...
0
votes
1answer
351 views

Performing CRUD operations on front end in wordpress

I'm currently trying to create a system where I can perform CRUD operations on a wordpress front end. I've seen a few plugins with shortcodes that allow this, so that is one possibility. However, ...
-1
votes
1answer
80 views

SQL to transform all email addresses in my DB in lowercase [closed]

how can I transform all email addresses in my DB in lowercase? I did an import and all addresses are uppercase and if a user registers again with lowercase the system thinks is another email. So I ...
0
votes
1answer
335 views

Connect to Ms SQL Server

I've been asked to develop custom plugins which will connect to a database hosted on MS SQL Server in different geographical location, i.e the website is hosted with a hosting service and the database ...
0
votes
2answers
64 views

How to Update post_modified of all wordpress post

i want to update all my wordpress post modified date and time to a specific date and time, i have a code to update it base on the id, but i want one to update all the row at once without putting the ...
0
votes
0answers
51 views

Lock wait timeout exceeded; try restarting transaction

I get the bottom error in the debug file. I don't know how can I solve it! خطای Lock wait timeout exceeded; try restarting transaction در پایگاه‌داده وردپرس برای دستور INSERT INTO `wp_options` (`...
0
votes
1answer
14 views

Correct PHP to output a single result of a Function with SQL Query

So I have created a function on a separate php inc page and want to output the single result of the function on another page. This is the function function get_all_rating_criteria_travel5(){ ...

1
2 3 4 5
15