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)

3
votes
0answers
608 views

WordPress it's cleaning a custom query_var to avoid sql injections?

I am using get_query_var function to get a custom query_var. This query_var will be used later in to query arguments to retrieve posts with: $the_query = new WP_Query( $args ); . My question is, ...
2
votes
0answers
35 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 ...
2
votes
0answers
31 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 ...
1
vote
0answers
46 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
0answers
24 views

Restose content from revisions - sql query

How i can restore all posts to the closest revision to a particular date via sql query?
1
vote
0answers
350 views

Include data from custom table in WP_Query

I'm building an Estate Agent website. They have a system where they add their available properties and sends them all to the main property portals. As part of this, the system also sends all the ...
1
vote
0answers
435 views

SQL query equivalent to WP User Query

I have the following WP user query code: //Get all users sorted by whatever $sorted_users = new WP_User_Query(array( 'orderby' => 'meta_value', 'meta_key' => 'satisfaction_rating', '...
1
vote
0answers
91 views

Pull data and display as rows and columns

I am a noob when it comes to pulling data from tables and fields of a WP database so I'll explain it as best as I can without it running into a thesis. I have a table called WP_answer. In that table ...
1
vote
0answers
80 views

delete duplicate comments

I found a solution for this a long time ago. Here is the code: <?php require_once('wp-config.php'); global $wpdb, $comment_content, $comments,$comment_ID; # First select all comments $query = "...
1
vote
0answers
243 views

Remove posts inside pre_get_posts using a custom query

I need to remove posts from admin listing, if their last child post author is different than the parent post author. I was hoping to use pre_get_posts, but can't figure out how to do this. Here's my ...
1
vote
0answers
68 views

Genesis framework comments broken?

I got a really weird problem. Im using a Child theme which using the Genesis framework. I was using Akismet plugin to stop the spammers and it was workin just fine. Recently i just made a comment by ...
1
vote
0answers
207 views

How to import a Typo3 database to a wordpress site?

I have a SQL database export from a Typo3 site. Does anyone know or have any experience of dealing with these cases?
1
vote
0answers
859 views

$wpdb->insert() does not Insert record in a table

I'm trying to understand and get hold of the $wpdb global object but can't seem to make it work. Basically, I'm trying to insert a single record into a custom table in wordpress DB. Instead of ...
1
vote
0answers
672 views

Get posts under a category with SQL

How can I retrieve posts under a category with plain SQL with out using WordPress native api's like get_pages? My Wordpress table wp_terms contains a term named Restaurants. I want to list the post ...
1
vote
0answers
101 views

Meta Query And/Or

My question is very similar to Meta Query with AND & OR? . This question was answered in 2011 by @Otto. With the exception that my logic is different. I want to query, for example, posts with ...
0
votes
0answers
40 views

WordPress get pagination on wpdb get_results

This is my favorites page codes. How do I gee the numbered pagination of custom wpdb result? $query ="SELECT * FROM wp_posts as p, wp_postmeta as m WHERE p.ID = m....
0
votes
0answers
10 views

Select metakey values from WP database only where posts are published (two tables)

I am trying to select metakey values from wordpress database like this: global $wpdb; $r = $wpdb->get_col( $wpdb->prepare( " SELECT meta_value FROM {$wpdb->postmeta} WHERE ...
0
votes
0answers
37 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.
0
votes
0answers
45 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
19 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
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
34 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
0answers
29 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
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
0answers
42 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
36 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
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
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 ...
0
votes
0answers
64 views

SQL in WordPress get_var() not working

I created a few tables in my main WordPress database. Table names are: cards scards I put a plugin that lets me use PHP in pages, I used it in my other WordPress sites successfully but in this ...
0
votes
0answers
16 views

Editing a Wordpress SQL table in Phpmyadmin, however its not saving

I'm trying to edit the wp_options table in Phpmyadmin, I can edit it fine using inline editing or the edit feature. Each time I log into phpmyadmin I can see the value has changed to the one I edited. ...
0
votes
0answers
106 views

I want to query for the 'post' and 'attachment' in wordpress using SQL query

How do I write a SQL query which will allow me to query for the 'post' and 'attachment' at the same time in MySQL? I am trying to get this information from the wordpress 'Posts' table. Please see my ...
0
votes
0answers
78 views

SQL / Select users depending on meta value - meta keys, sorted by a meta value - meta key not in the select

I'm trying to select users with one of several meta keys corresponding to a meta value, and to sort the results by a meta value associated to a meta key which is not in the select. In other words, I ...
0
votes
0answers
130 views

Exporting wp_posts and wp_postmeta as a single table entry per post

I’m trying to export all posts of a certain type (to run a report), and all the associated post meta data. I want a single entry for each post, with all associated meta data, e.g. “Middle Name” as a ...
0
votes
0answers
56 views

wpdb->update update the entire table instead of one row

I'm trying to use the update function of wpdb, like this: $wpdb->update( 'protocol_data_list', array( 'used' => 1 ), array( 'cod_protocollo' => $_POST['numero_protocollo'] ), ...
0
votes
0answers
64 views

Render a Wordpress menu from outside Wordpress?

I would like to render a menu in another system outside wordpress using SQL to fetch the menu contents and some logic to build the actual menu. I turned on mysql logging to see what wordpress was ...
0
votes
0answers
48 views

Delete duplicate media in SQL only

I have uninstalled WPML and deleted all WPML tables in the DB. Now, I have duplicate media (one per old languages) in my SQL only (not in the FTP). I would like to delete these duplicates and only ...
0
votes
0answers
29 views

Nothing wrong with SQL but still getting an error

I'm developing a plugin and I need to perform a SQL query with GET parameter. The code looks like this: if (!empty($_GET['editDoc'])) { global $wpdb; $id = $_GET['editDoc']; $table_name ...
0
votes
0answers
92 views

External SQL Database (Login Details) to update wp_users with new users

I have an external database which currently has a Username and Password field, which are plain text (password field not using any hashing). Is it possible for when I update this database that it will ...
0
votes
0answers
124 views

pre_get_posts with custom SQL

I have a scenario where there is a custom form on an archive page. I want to use pre_get_posts to modify what is displayed on the archive page, and show the paginated results. The issue is I first ...
0
votes
0answers
40 views

Insert the same row 3 times

I am trying to developing a plugin for body mass index. I am trying to enter a row while creating table in register_activation_hook. When activation is finished i see 3 same rows in database. Here is ...
0
votes
0answers
33 views

How do I update post based on meta_key in another table?

So I have a function that is called by the wp_schedule_event (cron job) once daily. The goal of the function is to set all posts with a field wpcf-engine-days-to-go that has a value of "0" to a draft. ...
0
votes
0answers
64 views

Show different content in the same URL

I have a blog powered by Wordpress. I need to show different contents in a same webpage according to the date. Say I have few posts with the url format: domain.com/post-01022015, domain.com/post-...
0
votes
0answers
98 views

Change permalink , keeping old structure with date

Currently on our website we have the /date/postname permalink structure with quite a number of posts. For SEO purposes we want to change it to /postname permalink structure but we want to keep the ...
0
votes
0answers
194 views

How can I avoid duplicate primary keys in SQL import?

I have two sites I'm trying to merge. Site 1 has 1500 products in a custom post type, with associated meta and an attached featured image. Site 2 has 250 products in the exact same custom post type, ...
0
votes
0answers
38 views

Insert query not working for non-logged in user

I am trying to create a function for count post views. for this i have added code in my theme function file. Here is my code: function processpost_views( ){ global $user_ID, $post; ...
0
votes
0answers
261 views

Link wordpress with a SQl + MongoDB + .NET

This may sound a bit crazy, I have a website using different DB, One SQl; one MongoDB, and a .net API I would really really love to be able to move this to a wordpress installation ( or Magento). ...
0
votes
0answers
33 views

Adding Database Tables for Reviews functionality that incorporates Tags/Categories

I'm wanting to build onto to the Wordpress database in order to give myself the functionality to create/retrieve customer reviews based upon tags/categories. More specifically, the reviews are not ...
0
votes
0answers
119 views

Add a custom field via PhpMyAdmin to all posts and pages avoiding duplicates

I have about 200 pages and 400 posts on my WP site. And I need to add one custom field (sidebar_config: left-sidebar) to all pages and posts. I have this for SQL query in PhpMyAdmin: INSERT INTO ...