Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

0
votes
0answers
18 views

wordpress sql query pagination

for example, I want to Page the remaining comments after calling 50 comments. the page where I call the function <ul class="list-group"> <h2 class="h3">gündem <div class="...
0
votes
0answers
26 views

WHERE on meta key SQL

Given this working query: SELECT `p`.`post_title` AS 'Auto', MAX(CASE WHEN `pmd`.`meta_key` = 'regular_price' THEN `pmd`.`meta_value` END) `Prijs`, MAX(CASE WHEN `pmd`.`meta_key` = 'aankoop_datum' ...
0
votes
1answer
18 views

SQL query to change the value of a Custom Field

I am looking for a SQL query to change the value of a custom field, but not on all posts. Some posts have in the "post_template" custom field a "temp1" value, and I want to change this value to "...
0
votes
1answer
23 views

Debugging wp_query orderby for taxonomy

I cannot seem to find where WP_Query adds the orderby clause to a SQL query. I am using this code: function wpd_team_taxonomy_queries( $query ) { if ( !is_admin() && $query->is_tax( 'team'...
-1
votes
0answers
18 views

Wordpress $wpdb->get_results returning null

I am trying to get values using the below code but shows null values. I checked the database and it contains all data but not able to retrieve the data. Thanks for the help in advance. <?php ...
0
votes
0answers
11 views

Can I replace the “Upgrade Network” with SQL query?

I have a WordPress Multisite network. When the WordPress version has been updated, I have to click on "Upgrade Network" for do same thing on all subsites. How can I replace this function with one SQL ...
0
votes
0answers
9 views

Relations between taxonomy terms for getting parent child nested Json objects and arrays

i have 2 taxonomies (cat) (subcat) and they have some terms(rows) for example , , i want make a relation like SQL data tables between the taxonomy terms for giving me a nested object of arrays in the ...
0
votes
0answers
6 views

Woocommerce - insert cart data to a a secondry database on a different server

so here is my situation I have a eCommerce website built with Woocommerce - wordpress that is hosted on Godaddy php server, and I also developed an ASP.Net application to serve couple of other ...
0
votes
0answers
19 views

Using a meta_value or postdate to to query and orderby

How do I structure a sql that: 2 checks if meta_value is in future or has no meta_value at all and 1 orders by meta_value (meta_key => datum_event), and conditionally if this meta_value is empty ...
2
votes
1answer
24 views

WPDB: how to get the value of a field in a custom database table

For my WordPress site, I would like to echo the value of a column in a row (determined by the user's ID) of a table in the database for my site. This table was created by a plugin so it is not ...
0
votes
0answers
11 views

Create user with sql if it does not exist in wordpress

Forgive me if I'm in the wrong place, I'm digging the Stack Exchange world. This functional sql code creates a user in wordpress: INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `...
0
votes
1answer
23 views

Query post with meta_query where date is not in future

In my args I would like to exclude posts where the datum_event is not in the future. Currently it only displays posts with datum_event values that are in the past, but because older posts don't have ...
1
vote
1answer
20 views

Databases - Submitting data from inputs to database [closed]

I am attempting to submit data to a table I have created within my database. For sanity sake I have called it 'wp_email_subscribers'. Including the wp_ prefix. I know there is a way to insert data ...
0
votes
1answer
36 views

Help posting values to DB on submit using $wpdb->query

I am not new to WordPress but this is the first time I have tried to use the $wpdb. I have set up a form: <form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']);?>"...
0
votes
1answer
25 views

Is it possible to query from external database? [duplicate]

I have an extarnal database that I want to show some data in my wordpress site. What are the necessary steps to achieve this? edit: I changed config.inc.php according to https://stackoverflow.com/...
0
votes
0answers
16 views

What's the easiest way to connect external database and display data on wordpress?

I want to use google cloud sql for keeping my data. The data is changeable from another application. I give necessary permissions to cloud sql but I cannot find easier way to show the data on the ...
0
votes
0answers
14 views

Moving attachment postmeta rows to new database

I am moving a lot of content from one existing (and damaged) Wordpress installation to another existing installation. I am trying to bring the media library attachments into the new site, but when I ...
1
vote
1answer
28 views

Including metaboxes from custom post types in global search — continued

I've seen several questions about including the content of meta-fields in a wordpress search. My question is not a duplicate of these. Background The issue I'm having stems from how meta queries ...
0
votes
2answers
20 views

Build filter for post-type + multi taxonomies + multi terms

I Need to build an interface with a filter set (a list of checkboxes) that the user can check and click 'filter' to search with in 1 custom post-type for posts with matching terms (there are 3 custom ...
1
vote
1answer
153 views

Order by summing multiple values

In a custom post type (products) I want to order products by summing multiple values based on user selection. I use custom taxonomies to filter the products. I could use the orderby meta_value but ...
0
votes
1answer
37 views

Is it best to avoid using $wpdb for security issues?

I'm using WordPress Multisite with multilingualpress. In order to get the href, outside of my navbar, to the page with the appropriate language, I am using an SQL query that queries $wpdb within the ...
1
vote
1answer
38 views

Renaming post IDs - Okay to do?

Is it possible to change the post IDs within the wp_posts table without causing problems? I ask this because I have a WordPress Multisite in which I separate the sites by language. Unfortunately, the ...
0
votes
0answers
21 views

update_option returns false in AJAX, how to debug?

I tried debug plugins for WordPress, but they only show the current page SQL queries. How to debug if update_option returns false? I am updating an object decoded from AJAX request with json_decode ...
-2
votes
1answer
22 views

why you don't Implement PDO for access every thing to database

that is.. why wordpress don´t use PDO if it is more secure, and prevent a lot of injections, and issues with security. Thakns
0
votes
0answers
18 views

Get count of each category depend on date - SQL query in WP

I would like to select all categories of my blog with count and date of create. I know that I have to convert post_date to specific month and then group my select by month(date) and category. However ...
0
votes
1answer
21 views

How to copy user_nicename value into user_login

a hacker put value "admin" into all user_login fields. i need to copy user_nicename value into the user_login so users can login. is there a SQL command i can run to do this task in bulk, as their ...
0
votes
1answer
18 views

I can't figure out what's wrong with this statement. $wpdb->query update

I'm trying to use the $wpdb-query method, but can't seem to get it to work. I get a 500 error when I try the following: $update_status = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}...
0
votes
0answers
23 views

function to generate custom field for Mailster newsletter from WPgens referral code

I’m quite new to WordPress – and coding in general except I did a lot of SQL, R Matlab etc during my studies a long time ago so I can learn if I know where to search :-). But php, javascript etc are ...
0
votes
1answer
19 views

Nested select statements not working

I have 2 tables I need to search. 1st table Name: Personnel Fields: id, lname, fname, department, extension 2nd table Name: department Fields: id, department The 2nd table has the full department ...
0
votes
1answer
74 views

Delete posts with word count less than x number of words

I searched a lot about this, found plugins that are out dated and consumes massive resources and finally do nothing, is there like an SQL line to delete all posts that have a word count like less than ...
0
votes
0answers
9 views

sql query for selecting btween two amounts

I am trying to achieve result by selecting dropdown between two amount range. echo '<option value="browse-events?city='.$browse_city.'&type='.$browse_type.'&price=Free">Free</option&...
2
votes
1answer
289 views

Updating WooCommerce variable product stock issue

Soo.. I've created CRON script, that each 1 minute retrieves an actual stock systems data, converts it for Wordpress/Woocommerce database table and updates stock. On database side everything looks ...
0
votes
2answers
42 views

Fastest way to display 5000 post titles?

I want to display all CPT titles on its archive. I don't want to use pagination. All must be in 1 page. There are 5000 posts. Echoing the_title on the archive loop works but it's slow. What's the ...
0
votes
0answers
20 views

Display data from 'comments_clauses' in comment object

I want to add display name from users table to the comment object in WP, but failed. I don't know where is the error in my code below. This is my code. add_filter( 'comments_clauses', '...
0
votes
1answer
23 views

Alter the cost of products using phpmyadmin sql query

What is the SQL query can i use in phpmyadmin to alter(update) the listed products cost in woocommerce. EX: I want to add or subtract $100 from all the listed products.
0
votes
1answer
20 views

How to Add or Change Post Title

How to add post titles with new titles via sql? example post title now "beddu". i want to adding/ change "Add beddu" thank before
0
votes
0answers
44 views

CPT with custom table? Create posts automatically?

Variations of this have been asked in the past, for example: HowTo: Custom Post Type (Meta) to Custom Table , but I am wondering if there is a better answer for my case. I have an SQL table with 30 ...
0
votes
1answer
17 views

Show Mysql table elements as pages in Wordpress

I am trying to build a WordPress site, but I need a specific functionality and I haven't been able to find a plugin for it. I'm going to be scraping sites info and posting the info into a DB (this is ...
0
votes
1answer
73 views

Slow Query On Search

Please I have a very slow query on my wordpress search, checking the processes it takes upto 40sec to execute using SHOW FULL PROCESSLIST; below is a sample of query SELECT SQL_CALC_FOUND_ROWS ...
0
votes
1answer
18 views

insert post fails after multiple postings

I have a script that automatically makes posts and uses insert_post() to do so. Running the script works but after a few loops (running insert_post()) the script just ends without any warnings or ...
0
votes
1answer
65 views

How to transfer categories (default) to custom taxonomy?

I wanted to move all my posts from the default post type into the new custom post type i've made. I was able to do it using this code: UPDATE wp_posts SET post_type = 'movies' WHERE post_type = 'post'...
0
votes
1answer
29 views

Delete/Replace words from X to Y in post content

I am looking for a way to search and replace some words in my database. I have many posts on one of my blog and i want to replace words using regexes. before publishing, I marked every place I wish ...
0
votes
0answers
66 views

Deactivation Hook does not remove database

If I deactivate the plugin, the database table does not get removed. It is removed only when i delete the plugin. Here's my code: <?php register_deactivation_hook( __FILE__, '...
2
votes
1answer
67 views

Advanced WP Query hogs the SQL server

I recently developed a website for a customer who is a estate agent. Included in the project is a post type called listing. This post type is used for all of their listings and additional information ...
-1
votes
1answer
27 views

Get all the related data from WordPress DB

I have 2 custom tables inside the DB WordPress is installed in, With one-to-many relation between both tables. Here are the two tables: posts table ...
0
votes
0answers
23 views

Why does DROP TABLE-ing the `wp_options` reset my user session?

If I do: global $wpdb; $wpdb->query("DELETE FROM wp_options"); Suddenly, I'm logged out. But how come? I thought all sessions are kept locally, surely, a reference to my session must be present ...
0
votes
1answer
49 views

PHP -> SQL Query with Summing

So I'm trying to display the sum of Paid Transactions for a customer's account: SELECT SUM(`payment_amount`) FROM `wp_gf_entry` WHERE `created_by` = '2' AND `form_id` = '37' AND `payment_status` =...
2
votes
2answers
160 views

How to make WordPress plugin check for database changes and then do something?

How do I for instance check if there is written a new comment in the database and then make my plugin register that there have been a change? I will use this information to do something in the ...
0
votes
1answer
48 views

Filtering posts for unique titles, only the most recent

I am trying to understand how I can fetch posts for an archive that: Have a unique title Are the most recent version of said unique title So, if I have 3 posts: title: 'ID1: My Title' date: 01/01/...
0
votes
0answers
30 views

Is there a way for two deferent themes to consume two different DB on a same WP instance?

Before you downvote, yes I know there is a lot of similar questions around the web. But nothing touches my specific situation and how I should approach this problem. I have a build a new theme for a ...