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)

0
votes
0answers
11 views

Function is creating too many queries

I have code that displays a list of categories and orders them by the number of ACTIVE posts in the category. This is determined by comparing the custom field of due date against the current date. If ...
0
votes
1answer
2k views

Using AJAX to run SQL statement and populate dropdown

I am trying to create a search where the user selects two different bits of data from the database and it then prints some results that meet requirements. I know I need to use AJAX, or something ...
0
votes
1answer
394 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
0
votes
1answer
259 views

Can't create posts with WP DB Abstraction Plugin

I have a WordPress site moved to Azure web site + Azure SQL using database abstraction plugin After that migration I'm not able to create new posts. When I click Save Draft it redirects me to the ...
0
votes
1answer
396 views

When sorting WP_List_Table, table sorts, but I also get SQL errors

Here's my lovely prepare_items() function: function prepare_items() { global $wpdb; $table_name = $wpdb->prefix . 'blah'; $per_page = 100; $columns = $this->get_columns(); ...
0
votes
0answers
20 views

How to optimize get post query

I have a dynamic Wordpress site with large number of posts (almost 2 millions), and need to optimize custom archive search query. This is what I'm using now and it takes ~0,5s (standard query_posts() ...
0
votes
1answer
17 views

Why my query does not run with prepare

Hi Below is my query and it works with prepare keyword on the localhost but whenever I use prepare keyword with my queries on live server the data does not show up and as soon I remove prepare from ...
3
votes
1answer
1k views

get_results on large datasets

I am experimenting some very disturbing problem using a custom SQL query. I have a custom MySQL table called trading_datas having 165 lines for 4,4Mo. One field datas of my table is a big serialized ...
0
votes
1answer
18 views

How to filter sql only for a specific post type

I have been trying to join a custom table with a regular wordpress query, but only under a specific condition (a specific post type). I have a single-event.php template that runs the main query, and ...
0
votes
0answers
15 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
8 views

How to Use WordPress SQL Database on Sub-domains or Directory

I have a domain website.com in English and want to translate a directory to Spanish website.com/es taking exact content from website.com Question: How can I use same database on this directory?
0
votes
1answer
636 views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
0
votes
1answer
6 views

How to set up prepared query using IN statement

I am a tad bit confused on how I would set up a SQL IN statement using a prepared query. Here is the code: $in = implode(',', array_fill(0, count($product_ids), '%d')); $results = ...
0
votes
2answers
23 views

How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?

I have a custom post type named store and I have a custom taxonomy city, I also have a meta box with a field that is stored with update_post_meta( $post_id, 'store_postal_code', $postal_code ); it ...
0
votes
2answers
2k views

SQL - Pull products of particular category from a remote WordPress woocommerce db

I connected to the db and successfully pulled products data. Now I want to to display products from specific category. The store is using woocommerce. The landing page is in different location so I ...
9
votes
7answers
45k views

What SQL Query to do a simple find and replace

Whenever I create a new website I first create a staging site on a subdomain like "stage.domain-name.com". After everything works correctly I export the database, open it in notepad++ and do a ...
0
votes
1answer
19 views

problem in inserting row to database

I have a custom table in database (named "wp_tasks") it has 5 fields. the problem is when i wanna insert the current time to this table it wouldn't, i checked for the first 4 fields, it works ...
0
votes
1answer
44 views

Add special meta box to custom post type

I have managed to add a meta box to my custom post type (see code below) Now I need to add another meta box. With this box I want to display / edit a value from another table called ...
14
votes
5answers
26k views

WP_Query with “post_title LIKE 'something%'”?

I need to do a WP_Query with a LIKE on the post_title. I started with this regular WP_Query: $wp_query = new WP_Query( array ( 'post_type' => 'wp_exposants', ...
0
votes
1answer
26 views

Clean up very big and very dirty database

I'm trying to clean up a database in order to move a website from a server to another. Database is more than 1gb, mostly posts revisions and spam comments. Is it safe for instance to do something ...
0
votes
1answer
23 views

Wordpress Custom Search By Alphabet and order by asc and sesc

I am new to word-press but i can easily work on core php and other mvc framework,acutally i want to add custom search for only subcategory post. The search will with below Search post By old to new ...
0
votes
2answers
424 views

Bulk move (or copy) from a custom field to the post content?

I need to move (or copy) the contents of a custom field into the main post body, replacing any existing content. I need to do this for a few hundred posts...Is there a quick way of doing this? I can ...
0
votes
0answers
24 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, ...
1
vote
1answer
16 views

Are database queries created using WordPress filters protected from SQL injection?

I'm using the WordPress 'posts_where' filter (https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where) to alter my queries as below: function filter_my_search($where=''){ ...
0
votes
1answer
28 views

Can not manually create a database ( db, user, pass ) for a plugin

So I was working on a plugin and I needed to cache some third party API access, and I needed to manually create a database upon plugin activation or upgrade. The caching stuff needs a database host ( ...
0
votes
1answer
23 views

Custom database query to validate data

I cant find any syntax for custom queries, use of $wpdb is new to me so can anyone help me solving this?? if(isset($_POST['submit'])) { global $wpdb; $tablename='wp_form_subscribe'; $myrows = ...
0
votes
0answers
22 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
1answer
19 views

WPDB SQL Ignore `post_status` Parameter

I use this SQL statement: SELECT * FROM wp_posts LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id ) LEFT JOIN wp_term_taxonomy ON ( ...
0
votes
1answer
21 views

Sum of Custom Meta written by Authour

I have a custom meta call post_views_count that collects the views of all posts... I want to create a query that pulls in all posts by a certain author, gathers the custom meta for post views and ...
0
votes
0answers
31 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
80 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 ...
-2
votes
1answer
43 views

If meta_key exists then don't select this post?

I'm trying to select all posts EXCEPT ones with a meta_key somekey. SELECT * FROM wp_posts JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id WHERE meta_key != 'somekey' But this is still ...
1
vote
2answers
175 views

Export / import Wordpress database

Is there a proper way of exporting and importing a big WordPress MySQL database to a new database? When I tried to do that in the standard way I run into 2 issues: All widgets disappeared and I had ...
0
votes
0answers
17 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
1answer
45 views

Alter the main search query to search posts by coauthor user name

I am using the Coauthors plugin: https://wordpress.org/plugins/co-authors-plus/ I have written some SQL in order to grab posts from authors whose display name matches the search query when searching ...
-2
votes
1answer
3k views

cleaning up safely wordpress wp_postmeta table

In a effort to facilitate maintenance of my site, optimise page loading , and also helping out db migration , i am trying to cleanup the wordpress database of my site. i ahve realised the wp-postmeta ...
1
vote
1answer
56 views

problem with sql query in wordpress plugin

I've got this and I dont know why its not working. It's not returning the ID from the first query so I can use it in the 2nd query. Nevermind the REFERER, its an external link it will refer from. ...
0
votes
1answer
8 views

Creates only one table and not the other

I have this function to create two tables when I activate the plugin. Only the wp_wpt_stats table are being created and not the wp_wpt_list. I know the dbdelta is picky, but I can't see what I'm doing ...
0
votes
1answer
41 views

SQL error on restoring database

I am running a database backup -- a 7 MB SQL -- using the phpMyAdmin Import function -- and getting an error, whose text doesn't really show where the problem is. MySQL said: Documentation #1064 - ...
0
votes
2answers
27 views

How to display a specific category using a custom Query in WordPress?

Hi I want to display a specific category from a custom query in WordPress. My code works fine and it gets the latest 4 posts, but what I want now is to retrieve a specific category. My code is below ...
1
vote
2answers
71 views

Complex WP SQL Query

I have tried the following SQL query without any success. Can anybody that have a better understanding of SQL help? Here is what I am trying to achieve: Get a list of all main events (ME) where the ...
0
votes
0answers
124 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
106 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?
0
votes
0answers
35 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 ...
0
votes
0answers
122 views

SQL query to get all nav menu items and their titles/label

I want to get a list of all nav menu items displayed in a menu having id "19" in my search page to match against the search string. I would like to get names of menu items as displayed on frontend. I ...
0
votes
1answer
51 views

Create Array from data in the OPTIONS table

Good Day everyone, I'm trying to create an array from data in the Options table of wordpress. My data all start the same way plugin_order_ and then name of the field information. Is there a way to ...
0
votes
1answer
68 views

Protect custom form from SQL injection

I'm trying to understand how to protect my custom form from possible attacks. I send a data via a form, let's say userdata, then I read it: $userdata = $_POST['userdata'] I put it into an array to ...
2
votes
2answers
50 views

SQL to check how many sites a user is a member of

I have a multisite installation and I'm working on creating a reporting plugin. One of the things that I would like to do is show the number of sites a user is a member of. Right now, I'm using ...
0
votes
3answers
344 views

Problems with moving my Wordpress site to another domain/server

I'm having problems moving a wordpress site from one domain to another. I've searched the site but couldn find a useful answer for my situation. Here's what i did: I made a backup of the website. ...
0
votes
1answer
37 views

Help with SQL query, how to add taxonomie terms with value stored in options?

i need your help in making SQL What i have: custom post type ( company ) taxonomie ( category ) applyed to cpt ( and has ct section select field ) custom taxonomie ( section ) applyed to nothing ...