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
1answer
23 views

show badge with count for pending items in custom post type

This code I have is working but I am not sure if it is the right way to do this. Basically when a user adds a record to a custom post type it goes straight to pending and needs an admin to publish it. ...
0
votes
0answers
10 views

restropress storage type - XML, Mysql, etc, does anyone know? [closed]

Does anyone know what type of storage method the WP plugin REstropress uses? IE does it store orders in XML or in a SQL table etc? I am trying to track down where it stores the active orders ...
0
votes
0answers
11 views

SQL Query - custom tax_query not working when querying two taxonomies

I have a created a custom table in my WP database called wp_opportunities which stores locations with their lat and long. I'm trying to query the table based on the taxonomy term set on the post ID ...
-1
votes
0answers
7 views

Woocommerce SQL Query to find products with no sales [closed]

My client wants to find products which have never had a sale. What is the SQL to do this?
0
votes
0answers
6 views

Excluded category from SQL query but not excluding posts from that category

I am creating a custom search for my site and written following query. I am getting problem with the query. I have excluded some category IDs like 144, 303, 333. It is excluding these categories but ...
0
votes
0answers
10 views

How to display both first_name and last_name meta values in Wordpress Using SQL

Am trying to loop bids on different posts by a specific loggedin user with uid=2 to display first name and last name of the owner of the post. However the loop or rather var_dump only returns 1 result ...
0
votes
0answers
8 views

Set products variations images as parant main image

The scenario is: a site with lots of variable products. None of the variations has a featured image. We need them to get their parent image - not jus in the front-end, also in the backend (as if I ...
0
votes
0answers
5 views

Wordpress Website Shows Download Box on New Server

What I did: I took backup of my Wordpress website with SQL DB and upload it to another domain but instead of homepage, it shows a download box to save it as "download". I tried disabling all plugins ...
0
votes
0answers
10 views

WordPress: SQL query to set TAG or CATEGORY if 1 or more words are written in post_title

SQL I need to set the TAG or CATEGORY in a post if there is a keyword in the post_title. Eg: IF "abc" word in post_title THEN set post TAG to "zzz" or IF "abc" word in post_title THEN set post ...
0
votes
0answers
16 views

Update post_meta table from other database

I need to take values from an old database to a new one. Specifically a plugin's meta value of WooCommerce products. I've got the same products data in both tables but the IDs are not coincident, so ...
1
vote
1answer
21 views

How do I see the mysql query generated by get_posts( $args )?

I'm trying to use get_posts( $args ) to get some custom post types. Is there a way to see the mysql query generated by the get_posts function?
1
vote
0answers
13 views

Querying wpdb using PHP

I'm a beginner trying to query a table in my wordpress database and would appreciate some pointers on where I'm going wrong... I've got a table of cricket statistics, and want to get the highest score ...
0
votes
1answer
26 views

SQL: How to find all attachments that are not used in any posts/pages/custom_post_types

I have a wordpress installation where the posts also contain attachments that were not embedded in the content by using the media library -> add. I would like to find all attachments that are not ...
0
votes
1answer
53 views

What is the equivalent WP_Query of a SQL Query?

The problem There is a post_author post type, the main post relates to post_author: every post has one post_author. I need to have a list of all post authors to be sorted in a descending order by ...
0
votes
0answers
28 views

Fix Potential Security Issue in Custom Taxonomy Search Functionality

I want to add some functionality to a client WordPress site that allows you to include taxonomy terms from custom post types in the Wordpress search, and come across the following answer: Include ...
1
vote
0answers
10 views

SQL mass removal query for pending subscription [closed]

I have in a woocommerce shop 69 000 "pending cancelation" subscription. Is there anyway to make a mass removal of those by SQL ? Here is the URL settings to display them : post_status=pending&...
0
votes
1answer
13 views

Find locations of all featured images of draft posts via SQL

I'm trying to get the file locations of all featured images used in draft type posts via SQL and phpmyadmin. posts type attachment should hold the location of the image in the guid column. SELECT ...
0
votes
1answer
35 views

Woocommerce - get daily sales meta

I am writing custom woocommerce plugin. Does woocommerce has any daily sales report of each product? I know, that get_post_meta can show total sales of certain product, but I need to show sales of ...
0
votes
0answers
20 views

Insert and retreive data from custom database from Wordpress page

This is the first question I'm asking here, so I'm open to any feedback on how to clarify my problem/question! I have created a small javascript game on a wordpress page with "custom html". I'd like ...
0
votes
0answers
12 views

How can I automatically make a post for every entry in my database?

I am very new to WordPress development so I apologize for any clear lack of understanding present in my question. I am hoping to make a review website for podcast episodes. I have used Python to web ...
0
votes
0answers
20 views

Limit total number of post and post per page with get_results

I'm using a custom table with a additional column, so I can't use regular wp_query. My code is working great except for the total number of post. I want to display 5 results per page (which works ...
0
votes
0answers
21 views

Specific SQL Query to filter certain WooCommerce products

I've written a script that generates a .PDF based on products in the WooCommerce store, the idea behind this is that a client can print it, fill it in and fax it to the company. This works all fine, ...
0
votes
0answers
7 views

SQL: trying to update posts that have certain custom meta

struggling with an SQL command.. I want to change a post type from 'post' to '2month' that have custom meta (low_jobs = 'under 100') and do not have certain categories UPDATE wp_posts.ID SET ...
0
votes
0answers
27 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
23 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 ...
1
vote
0answers
59 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
51 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
61 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
187 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
33 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
24 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
57 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
28 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
18 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
12 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
18 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
27 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
25 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
24 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
98 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
27 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
30 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
16 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
13 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
124 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
16 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
2 3 4 5
15