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

Query to import posts to custom post type categories

So I've never done this before, but I'm migrating a websites database into another database that I'm working with, and I want to know what the best possible way is to put posts in their respectable ...
0
votes
0answers
11 views

WordPress creating excessive joins on meta_query with search

I've a pre_get_posts filter with a check for main query and search, in this check I add a meta query: $meta_query = array( 'relation' => 'OR', array( 'key' => 'exclude', 'value' =&...
0
votes
0answers
16 views

SQL database import #1046 error

As I am reuploading a WP website backup on a new host and importing the SQL database from phpMyAdmin, how do I solve this #1046 error ? Error SQL Request: — — Table structure for table ...
0
votes
0answers
21 views

How to get all products from an order including variations via SQL query?

I have searched a lot and hope someone has an answer. I want to run a query in the Wordpress/Woocommerce database and fetch from an individual order, all details, including the variations of a ...
0
votes
0answers
9 views

WP_Query adds “(wp_posts.ID = '0')” so no results are returned

I am doing a very simple WP_Query: $query = new WP_Query([ 'pagename' => 'some-post-slug', 'suppress_filters' => true // used by WPML to search in ANY language ]); However, the ...
0
votes
0answers
14 views

SQL query hanging php

I'm having issues with a fairly large WordPress site creating 45+ php-fpm pools. My hosting company says it is some long running SQL queries causing the problem and gave me this: +-----+-------------...
0
votes
1answer
28 views

I want to run Sql Query in script how can i do this

Thats What I tried But it give console error. i didnt understand how can run this i Have pass jquery variable to sql query but it isnt working <script type="text/javascript"> ...
0
votes
0answers
30 views

Update WooCommerce stock status with SQL query if stock value is greater than 0

I'm attempting to update a large product catalogue using a SQL query via phpMyAdmin if: the _stock_status = onbackorder the _stock > 0 Queries attempted: Update wp_postmeta Set meta_value = '...
0
votes
2answers
31 views

Is my way to change WordPress server is correct?

I'm in the process of changing my web host. I'm wondering about the cleanest way to migrate my WordPress blog. I'm far from being a WordPress expert, I only use it to publish a few posts. Could you ...
0
votes
0answers
17 views

WP Missing first revision with wp_get_post_revisions()

I'm using Wordpress native revisions and I've found a little problem. I want to return a list of revisions to the page however my first published content is lost everytime I make a change. The best ...
0
votes
0answers
17 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
23 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
9 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
13 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
11 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
23 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
20 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
19 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
90 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
26 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
25 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
13 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
38 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
14 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
148 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
20 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
39 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
20 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
72 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
171 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
17 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
41 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
45 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
22 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
150 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
740 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
58 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
37 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
18 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
297 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
42 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
13 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 ...

1 2 3 4 5 14