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
9 views

Woocommerce Backend Search by Title and SKU

Good morning, i'm trying to extend backend product search by using this function without success. This snippet works only in Title and i need to add also in Metakey SKU. I have tried extend by using ...
0
votes
1answer
18 views

SQL query to change custom field in Wordpress database

I'm newbie in SQL questions, and today i have a big problem. I need change many fields in my SQL, about 4,5k. But have some rules to the query change, to don't change wrong fields where don't need ...
0
votes
1answer
12 views

Bulk find & replace on Wordpress posts/pages (minus image paths)

I'm dealing with a tricky issue and wondering if anyone has a good way to solve this. I am trying to change everything on my Wordpress site that has "2019" in my posts/pages with "2020", however when ...
0
votes
0answers
8 views

Get name of all term which is duplicate using Mysql

I am coding something to get all duplicate term which has duplicate name using MySql query. The issue I have currently is I am getting the records in a single occurrence I need all data which has same ...
0
votes
0answers
9 views

dbDelta change PRIMARY KEY

I have a table with a composite primary key (call_id, submission_id). Now, I would like to change the composite primary key (call_id, submission_id, version). The code I am running is similar to the ...
0
votes
0answers
10 views

“Additional CSS” data keeps reverting back to default example, multiple rows in database created

Not really sure the best way to word this. WordPress stores the CSS in Customizer->Additional CSS in the wp_posts table, with the post_type set to 'custom_css' and the post_name set to the theme slug. ...
0
votes
1answer
15 views

How to get products without tag?

Can only with SQL to that? I think with PHP I can do that, taking all product and then taking product with tag and compare those. But can I do that only in 1 line of code by SQL?
1
vote
0answers
15 views

Wordpress WPforms customization

Firstly I would like to apologize because my question may be a little bit nooby. For the educational purposes I am building app to keep several different records in DB and then make custom query from ...
1
vote
0answers
20 views

How to verify wp user password by sql query in wp? [closed]

I want to verify the user password without function only by the SQL query.
1
vote
1answer
18 views

Get ALL post ID's export list (Only id's. Php or sql not important )

please help me. I dont know How can I do. I need list all posts IDs. export need 1 3 5 6 7 8 9 . . . . Please help
0
votes
0answers
18 views

Slow wordpress search page

When I search on my wordpress (woocommerce) it takes 50 seconds to load. According to Query Monitor the problem is this query. SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON (wp_posts.ID = ...
2
votes
1answer
86 views

Block search SQL from happening

I need to block some accesses to search results not the whole page, just the results. The problem is, I need the search SQL query to not happen AT ALL. (I can conditionaly hide the output loop ...
1
vote
0answers
24 views

How do I run SQL queries on a WordPress web page? [closed]

Whenever I Google this it brings up pages related to Database management. However, I want to run this in the actual webpage. For example: You go to a webpage where you can practice SQL: I.e. you ...
2
votes
1answer
24 views

SQL User Query by Multiple Roles using PHP

I can successfully get all my WordPress users using the following code: global $wpdb; $sql = 'SELECT * FROM ' . $wpdb->users; $users = $wpdb->get_results( $sql, 'ARRAY_A' ); However, I need to ...
0
votes
1answer
12 views

Duplicate rows in meta table, any known relations in WC?

I am doing a migration from very old to current wordpress/woocommerce and while investigating the data I found out that there are more than one row for a products _stock meta key. The same for other ...
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
27 views

Woocommerce change the price of products in the database

I'm trying to adjust the price of products in the database. I need to customize products that have custom taxonomy manufactory with id 270. I can change a simple product with this code: UPDATE ...
0
votes
1answer
13 views

A query to substitute images paths in gutenberg (website migration)?

I was used to do something like update wp_posts set post_content = replace(post_content,'http://dev.example.com/website', 'http://www.website.com'); This seems not to work anymore for texts that ...
1
vote
2answers
80 views

How to delete users with no order history through phpmyadmin sql?

I have a wordpress ecommerce website which I have begun to update after not touching it for over a year. The first thing I did was implement reCaptcha into all inquiry and contact forms to reduce the ...
0
votes
0answers
15 views

How to convert custom fields (ACF) to custom taxonomies

We have differents fields (checkbox choices) associated with custom post type. This cataloguing process no longer works. We would like to migrate ACF to custom taxonomies and retain choises. It's ...
0
votes
0answers
38 views

How To Toggle User_Meta in frontend in a form using PHP

I am trying to make a small form, that just has a submit button, and on submission, it should toggle user meta for the WordPress user. The button exists on frontend after content of post, and has a ...
0
votes
2answers
19 views

Running a PHP SQL script on a wordpress page

This is a very basic question. I am using Serverpress for local development.I have been trying to create a dynamic dropdown.I did some reading and I found an example html,php and jquery script that ...
0
votes
0answers
70 views

Query product's image path by category WooCommerce database?

I am writing a small query to grab image path and object ID from Woo_Commerce database. I am join taxonomy and relationship table to achieve this but somehow I am making mistake I can't realize. I ...
0
votes
1answer
107 views

How to get the list of WooCommerce product image of a certain category from database?

I am trying to display WC product images (thumbnails) or just get the url to that image from database. But I can't seem to find the column where the url are stored with the following. One thing I want ...
0
votes
0answers
14 views

Get and Update Most Meta Value as an array in HTML form

I'm trying to update post meta for a meta edd_download_files the meta is in the form of an array. It is from a plugin so i can do it via admin, but still there is need to do it programmatically. $...
0
votes
2answers
33 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
1answer
41 views

How to speed up “My Account > Orders Page” on Site with More than 200,000 orders?

On my account>orders page, the slowest query is the following: SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( ( ( ...
0
votes
0answers
20 views

Empty posts return an HTML comment

I'm using the script from this answer to exclude empty posts from the main query. It work well, but since the new WordPress editor, some empty posts return a comment rather than an empty string. i....
0
votes
0answers
14 views

How to merge select queries from wp_term column?

I am returning attributes values from wp_term and this is one of my queries for one attribute, say color. And I have the same queries for other attributes. I am looking for a way to merge them all in ...
0
votes
0answers
120 views

how to retrieve specific product attribute value in an sql query?

I am looking for some suggestion on how to run a query on wp-term with multiple "same column name as different attribute name" bottom line I am trying to query woocommerce products + all their ...
0
votes
0answers
10 views

in WordPress Loop update_user_ meta with Current Month and Year as Meta_Ley

I am making a page for my wordpress authors to see there stats. For the same, i first loop through all author ids, then i loop through all of there posts, and sum the post views meta key for all. I ...
0
votes
1answer
14 views

What steps do I need to take to install a local copy of a live website?

I need to create a local copy of a live site for development purposes. The live site is 30GB+ in size and so I don't want to download all of the uploaded media. I have copied all but the uploads ...
0
votes
2answers
520 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 ...
1
vote
1answer
35 views

Get Current User Id Inside a Loop Returns 0 For a Shortcode

I am having function, which has a loop for all the posts of given author. I use get_current_user_id() but that does not seem to work while inside a loop, or may be the shortcode troubles it. My ...
1
vote
0answers
36 views

WP Query related posts by tags

I want to display related posts ordered by multiple tags. So I need to create a function what will query posts with the most number of tags in common and display them in descending order. But also it ...
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
2answers
208 views

get all posts in custom post type by ACF field value

I have a custom post type with custom fields(advanced custom fields plugin). one of the custom fields named program_id. i can`t understand how to get all of the posts in that CPT where the ACF field ...
0
votes
0answers
21 views

How to identify the location of wordpress Query

There is a problem in my WordPress dashboard that the filter button in the media attachment thrown an SQL error every time with the query. In that query I Found AND statement and parenthesis which is ...
0
votes
0answers
33 views

Menus Problem - “widget setting ID: nav_menu_item[]” error - 84540 rows of “0”

I have a problem with a WP Multisite where only sub-site is misbehaving. All other subsites work OK On this problem subsite, I can’t open Customise – it throws an error … Uncaught Exception: Illegal ...
0
votes
1answer
12 views

how to SELECT meta values that are not null?

I have a rating system for our products but there is an issue: by the code, that will SELECT all comments in commentmeta table that have rating as meta_key. even those who do not have a rate (the ...
0
votes
0answers
18 views

Find posts where the featured image is also inserted within the post body itself

I am looking to find all posts in my Wordpress installation that have the post featured image also embedded within the post body itself. Given that my theme shows the featured image and also of course ...
0
votes
0answers
33 views

Safely changing UserID's, re-using deleted UserID's and automatically using deleted userID's instead of an increment

I'm looking for 3 different solutions all relating to user ids, I'm needing a solution to safely make changes without destroying the site. Issue 1: I am wanting to change the userID of a user from ...
0
votes
2answers
25 views

How to Assign / Move all Deleted post to a category

I have a database of 50,000 articles, One of my categories contains post of 30k, I mistakenly Deleted a category that contains 30k Post, But all the posts still exist. I have search google for the ...
0
votes
1answer
207 views

Get the exact SQL query that get_posts() generated

I am working on a WordPress that someone else started and then disappeared. She created a few custom content types and variables using different plugins and I now want to access the data sets in the ...
0
votes
2answers
27 views

How to get EVENT based on startday, using BETWEEN

I have a SQL query that get all events ordering by Startdate, and i define startday as $today. but this query didn't take events that start yestarday and that endday is tomorow. how can i make my ...
0
votes
1answer
32 views

SQL - Shorter way to query user and usermeta data

I'm looking to query a bunch of user and usermeta data into a single table. I'm able to do so by creating multiple temporary tables and a pivot: create temporary table meta select u.ID, u....
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
1answer
28 views

Why does changing Database Table Prefixes result in loss of content?

As to add an additional layer of security, to an eCommerce website I am working on, I have changed the default Database prefix from wp_ to wp_additional_prefix. To do this, I opened the wp-config....
0
votes
2answers
137 views

How to create multiple database tables on plugin activation?

I have an activation hook to create 2 new database tables that don't exist, only the second table is created from this code: public function add_tables() { // Global $wpdb ...
0
votes
1answer
82 views

update acf field value using sql query?

Any example to update acf field value? I am newcomer in acf fields. I need to use sql code. the field is numeric and the name is “totalviews”. I want to update the totalviews by +1 using sql only ...