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

learn more… | top users | synonyms (1)

1
vote
0answers
21 views

UPDATE on SELECT results. A SQL query to swap Author with Meta Box value

I inherited a project where, for some reason, the previous developer make a custom post type for authors and a custom select listing all those authors cpt titles in the post edit screen. This led to a ...
0
votes
1answer
27 views

How to make MySQL search queries with quotes

Hi everybody I run a wordpress based website and I'd like to store the search queries called by users to use them as analytics data to know what's most searched etc... So I have a custom table where ...
0
votes
0answers
17 views

How to escape a url to achieve this format: http:\\\/\\\/111.111.111.111\\\/

I'm seeing some site URLs escaped with slashes in this format, http:\/\/111.111.111.111\/, when exporting a Wordpress database to an .SQL file to move the site a new domain. What function would I use ...
0
votes
0answers
33 views

How can i change posts dates random?

I have totaly 5k content. I need change all of them dates. How can i set randomly dates? SQL? Example from 01.01.2010 to 20.06.2016 everyday can be dates.
-1
votes
0answers
9 views

how to execute an SQL query in the visual editor [closed]

I would like to know there ability to run sql request in editor in admin wordpress when creating a post. thnaks
1
vote
1answer
29 views

Archive post by meta value + 24hours

I'm using this code to archive some custom post type : $where .= " AND wp_postmeta.meta_value >= now()"; The metavalue is a date field. On the day of the value of the datefrom has been setup the ...
2
votes
0answers
33 views

my function doesn't return my post from today

I'm using gravity form to create some custom post type - as events. Everything is working great, There is some date field to setup the event from x to y date. ALl of this working great. However, I ...
0
votes
0answers
34 views

Advanced search query select from custom table

Hope that anyone can help me with this problem. I have 7 columns in my tbl2014wines custom Wordpress table. I am trying to create an advanced search feature that allows users to search by wine_name, ...
0
votes
0answers
18 views

Combined filters

I have a problem and i'm really stuck on this one. I have a small 'woodshop' and i want people to filter the results. The case: When i check multiple brands, the types should be updated. But when i ...
0
votes
1answer
16 views

Add commentmeta custom field to every published comment with SQL

I am trying to add custom commentmeta "likes" with 0 as default value to every posted comment. I have this query but I dont see any error there, but still it doesnt work. Can anyone help me to solve ...
1
vote
2answers
44 views

Need help writing a $wpdb query

I am trying to search through post meta for keyword matches but I'm new to MySQL and I don't know how to write my query. I can write a basic query for post_title matches but I don't know how to ...
0
votes
1answer
36 views

I can't write in my DB using $wpdb->insert

Building a plugin I'm trying to insert something in my DB but isn't works! My code is like that: global $wpdb; $table_name = $wpdb->prefix."mytable"; $wpdb->insert( $table_name, array(...
2
votes
0answers
26 views

SQL Query to copy value of a meta_key into another meta_key

I am trying to figure out how to replace the value of one advanced custom field with the value from a different custom field. Would anyone be able to help me structure a SQL query that will do this ...
0
votes
1answer
42 views

How do I get my suggest to only suggest one taxonomy?

I am using the built-in wordpress suggest plugin to call the entries from the terms table. Using the following sql query it spits out all terms: $query = 'SELECT term_id,name FROM ' . $wpdb->...
0
votes
0answers
16 views

Use remote image URLs as featured images/thumbnails [duplicate]

I'm working to migrate a site from Drupal (version 6) to WordPress (4.5.1). It has ~50,000 posts, almost all of which have one main image that appears in a large version on the post itself, and in a ...
1
vote
0answers
30 views

The word 'exit' in a content box causes WordPress to serve a 'Not Found' page [closed]

I've been developing with WordPress for years, and this is a new one. When the word 'exit' is included in the content of a post, even if inside another word like 'complexity', the post will not save. ...
0
votes
1answer
35 views

wpdb query on custom table not working [closed]

I want to show one custom table from my database on which WordPress is installed. So I googled this code: <?php $results = $wpdb->get_results( $wpdb->prepare("SELECT * FROM sparte-...
0
votes
1answer
27 views

Update field name without losing the value

So I have this photography website using ACF with flexible content. It has approximately 300 posts. Due to requirements, I need to update the name of some fields. I've tried the following query: ...
0
votes
2answers
38 views

WPDB Placeholders and second argument for prepared statements

How can I set placeholder and second argument for that kind of sql prepare $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND ID IN ('".implode("',...
0
votes
0answers
32 views

Storing Unique Data on the Database

I have created a custom table on my database using the code below: function dbcreator_activate() { global $wpdb; $table_name = $wpdb->prefix . "ftbstatistics"; if( $wpdb->get_var('...
0
votes
0answers
28 views

Custom database query with accents returning no results

I have an issue where using accents in my custom database query (wpdb) returns no results. $wpdb->get_results( "SELECT * FROM table WHERE city = 'Montréal'" ); Returns nothing, while $wpdb-&...
0
votes
1answer
27 views

Scheduling posts in database

I have more than 100 posts to schedule. I have set the date and the status (future) with a SQL query. But when the time comes the post is not published and in desktop I can read message 'Schedule lost'...
0
votes
1answer
34 views

wpdb get posts by taxonomy SQL

I need a list of posts of a specific post_type plus the name of a custom taxonomy term. This is what I got so far SELECT p.post_name,t.name as clientName FROM $wpdb->posts AS p, $wpdb->terms ...
0
votes
0answers
25 views

send email to user

I want to send an email to users based on the value of the database. To clarify if the user exceeds the value set in database, send him an email Automatic But I do not know where to write the code in ...
0
votes
0answers
22 views

Function get_results doesn't working

This is very very strange, 'cause when I run this query in my MySQL terminal, works perfectly: Query: "SELECT a.post_id, a.meta_value, a.meta_key, b.meta_key, b.meta_value FROM pdb_postmeta AS a ...
0
votes
0answers
22 views

Limit results of custom query to current category

I have created a geolocation system for a custom post type of services and have been working on a query to limit the results based on address/distance entered by the user. Everything seems to be ...
0
votes
3answers
51 views

Get all posts from db between 2 specified months

Am trying to get wp posts between two specific calendar month. The problem is, it is a annual year. So month starts from May and ends in Next year April. So each year output should start from May of ...
0
votes
1answer
26 views

Use variable in SQL statement

I have this: <?php $jerseys = $wpdb->get_results("SELECT order_item_id, order_id FROM wp_woocommerce_order_items WHERE order_item_name = 'Mystery Jersey'"); echo "<p>Jerseys</p>"; ...
0
votes
0answers
17 views

Why Do I Still Getting Duplicate Rows in SQL?

I'm creating a Custom Freight System which stores the order and the products requested by the user into the WordPress Database. The Problem When I insert the product into the wp_my_custom_products ...
0
votes
2answers
89 views

What to create new post using wp_insert_post, but it repeat the post infinitely

this is my source global $page; $page_exists = $page->post_title; $another_db_user = 'user'; $another_db_pass = 'pass'; $another_db_name = 'name'; $another_db_host = '...
0
votes
2answers
82 views

Wordpress wpdb->insert returns int(0) => doesn't insert anything, no errors!

I am really clueless. I want to do an insertion in my WordPress plugin the problem is it doesn't return any errors nor it insert the stuff! I don't know how to fix this and really need your help. In ...
0
votes
0answers
20 views

WP_QUERY with alternating post types and pagination [duplicate]

I want to show both regular posts and a custom post type (event) on the homepage in a single loop. The event post type needs to be ordered by a custom field for the event date and show future events. ...
1
vote
1answer
35 views

Cron While Editing Post

I have a multi-author blog, on which there are two schedule cron functions. The first function moves all public posts in the pending status after 365 days: if( ! wp_next_scheduled( '...
0
votes
2answers
171 views

How i make a custom sql query for Woocommerce

hello i have an ecommerce with Wordpress + Woocommerce, just yesterday a hacker boy or...i don't know moved all woocommerce products in to the trash.... there are lots of products and default ...
0
votes
1answer
45 views

How to order custom user list columns by datetime?

I am trying to add the ordering options to some custom user list columns I added in the Wordpress admin. This is my code : function mmm_user_sortable_columns_query( $userquery ){ if( 'test_date' ...
0
votes
0answers
40 views

SQL to update custom post field

I tried to update a custom field but I can't to this... I have a custom post that that I used for a fill months. Now I create a new date custom field called "data-edital". On the new posts, I put the ...
0
votes
0answers
32 views

Fast User Query Using SQL vs WP_User_Query

I've found that WP_User_Query() is very slow when dealing with more than 1,000 users and I have decided to use custom MySQL queries. In my code below, I pulled only user_id to make it work faster and ...
0
votes
1answer
69 views

WooCommerce - Order_itemmeta - Need to add meta_keys to table

I need to add 3 meta values to each order_item to the woocommerce_order_itemmeta table. Any suggestions how to create new meta_keys to be included in the table for all order items?
0
votes
0answers
111 views

How to get last order number in Woocommerce and insert next?

I am developing an offline product to retail. This will be sold by a distributor NOT through my website. I have an sequential order reference system based on woocommerce such as 152, 153 etc. I want ...
0
votes
2answers
72 views

Convert a category of posts to a custom post type using (MySQL) queries

I am trying to convert over 2000 posts with a category of hp_operator, to a custom post type. I usually use the "Convert Post Types" (a plugin) for tasks like this but with the amount of posts here ...
0
votes
0answers
33 views

Retrieving meta values from database to CSV

I am working on this database in which the data is serialized and it's in a multidimensional array. I am trying to retrieve the data from WordPress into a CSV file. I read that WordPress automatically ...
0
votes
1answer
33 views

$wpdb query for price in custom field value

A classifieds list site have only 3 criterias when searching products: the common search, category and region (for ZIP, city or full address) It's not enough and I really need to include a basic price ...
0
votes
1answer
25 views

Include post_status check within $wpdb query

I've got a function that returns a count from the database for publish posts that match the product ID to the post meta ID (both are the product type). I've realized this query returns unpublished ...
3
votes
1answer
160 views

Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)

I have series of sorting issues on a page that I'm trying to figure out but so far to no avail. Sorting a list of CPT posts which are listed under associated custom taxonomy terms I found this piece ...
-1
votes
1answer
49 views

SQL command to convert all tags in lowercase?

I'm looking for a SQL query command to convert every single tag in every post ever used to be converted into lowercase.
1
vote
1answer
127 views

What SQL / WordPress queries would need a nonce?

I'm a PHP / JavaScript developer and I'm new to WordPress. Our company's website is build upon WordPress. However I created many custom PHP pages without minding the WordPress framework much. When ...
0
votes
0answers
19 views

SQL query works only if inclusive

I have a Wordpress website with, say, 5000 articles. I am trying to apply a query to filter all the posts with featured images not listed in some specific categories. I started with: SELECT ...
1
vote
0answers
41 views

Optimizing Wordpress Queries - Removing Group By ID

I'm looking to transform a few queries that I'm running through get_posts into direct MySQL queries, in the hopes of optimizing them further. I see that my initial get_posts query, once built and ...
1
vote
2answers
45 views

Wordpress SQL Issue not returning correct reselts

So, I have been working on an SQL query involving the users and usermeta tables in wordpress. I am not getting the correct results. I have the following query written SELECT * FROM ...