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
1answer
35 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
38 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
1answer
14 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 ...
1
vote
1answer
17 views

How change user type from contributor to author

I have 2058 users who are contributors. I need to convert their role to author. How can do it by SQL?
0
votes
2answers
37 views

Better way to migrate to server?

Migrating between local and server with Wordpress (SQL) is a bit time consuming, and I'm wondering if there is a better way to do it. With Drupal, there is a module called BackUp&Migrate, which ...
2
votes
1answer
38 views

SQL query to get adjacent posts from search query

I'm busy rewritting a custom function I have recently written to get adjacent posts according to a tag, category, custom taxonomy term, author or search value saved in the URL I'm using the structure ...
1
vote
0answers
51 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 ...
0
votes
0answers
11 views

What are the steps to migrating my blog to a new host?

I recently bought hosting service with Namecheap. I backed up my db from my previous host and now want to migrate everything. I was restoring the db with phpMyAdmin, uploading the sql file, but this ...
0
votes
1answer
18 views

WP Sql query multiple where clause

I'm trying to get the users that have registered after a specific time (this case $today) and who have the newsletter field true and the account false. This is what I have so far but the result is ...
1
vote
1answer
46 views

Add custom fields to search

I want to add a custom fields ("introduction" and "ensavoirplus") to search of Wordpress, but the SQL code is not exact. I don't understand if i do a mistake or if WP don't can do this. But my attempt ...
0
votes
0answers
36 views

How to merge 2 WordPress sites?

I have 2 WordPress sites, A and B. Each of them has users and posts. Now, I want to merge these sites. Points to be noted- A has 1000 users and 2000 posts. B has 500 users and 3000 posts. There are ...
0
votes
1answer
35 views

WPDB update row with != in where clause

I'm using wpdb to develop a plugin to add a custom form to wordpress. To update a row, I use an array and wpdb->update(). WP Class Reference says: My SQL code should be something like UPDATE ...
1
vote
0answers
22 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 = ...
0
votes
1answer
21 views

Creating a “forum” - showing last post or last commented post

thanks for reading! Im creating a forum just using categories and posts. I'd like (as most forums do) to show the last commented post or the last created post (which ever is newer) next to the ...
0
votes
1answer
35 views

Front end access to a SQL data repository - recommended way?

Building a general data repository, not necessarily related to WordPress elements. What is the recommended way of doing it: Using custom post types? or Building new SQL tables? Please elaborate. ...
0
votes
2answers
136 views

Insert Query not working in the form

Many people has asked the same question, I have read those things and mine is different, I am trying to insert some values inside the database from the form but it's not getting inserted I have a ...
0
votes
0answers
365 views

Custom SQL Query: Get all posts with category id and a concated list of tags on each post

I am trying to select all posts from a WordPress database, include few fields on each post, but most importantly I would like to also select the "category id" or each post, and ALL the tags that ...
0
votes
1answer
27 views

Debugging WordPress

Looking for advice on debugging sql queries. I find that plugins and themes are causing heavy queries and slowing performance. Any easy ways for doing this? Tools? Shortcuts? Thanks! Daniel
0
votes
1answer
33 views

Minimize Performance Issues of MultiSite Large Number of Tables Created

I am deploying WordPress MultiSite and if I get a decent amount of users, I will have thousands of database tables to support all of these sites. I like the idea of consolidating all of these tables ...
0
votes
1answer
41 views

Query to get data of a post, if in category?

You would think you could use $query = new WP_Query(array( 'p' => $idofpost, 'cat' => $numbers )); to return the post if it is a certain category (or categories, or -number to exclude ...
0
votes
1answer
171 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'=> ...
1
vote
1answer
34 views

Custom query to get terms from post ids

I want to get the terms object by given posts ids. I don't know much about sql, and this kinda complicated for me. Here is what i tried: global $wpdb; $taxonomy = 'category' $term= ...
0
votes
0answers
29 views

Unable to replace text string across site

There is a text string (a little over 1000 characters with spaces) that needs to be replaced across the entire of my website. The text recurs over 300 times on my site, is identical, and was been ...
0
votes
1answer
57 views

List of ways to access WordPress database?

I'm trying to get a complete understanding of how WordPress works with databases. I've read the documentation but I'm getting confused by all the different approaches available. So far my ...
0
votes
1answer
83 views

Bulk update post slugs through database

Is there a way to bulk update permalinks through the database? cause I have like 20k posts and all I want to do is add a prefix to the permalink. I could just manually update but that's too tiresome ...
0
votes
0answers
51 views

SQL command to export post_content from wp_posts using phpMyAdmin

I'm trying to select all the data from within the post_content column in the wp_posts table in WordPress so I can export/import it into a new database. Somehow this content didn't properly make it ...
0
votes
0answers
58 views

WP Query to order posts by multiple meta fields

This question might have an answer already in the forums, however I still wanted to ask it as this is a different more complicated version of the problem. The story: We have 2 meta fields for ...
0
votes
0answers
84 views

Import SQL tables from SQL file on plugin install

I'm building a plugin, on installation of the plugin it needs to create several tables. Now I found out that I can do that in the plugin code sorta like this.. // Function to create new database ...
0
votes
2answers
313 views

How to display posts of 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 ...
0
votes
1answer
22 views

SQL - JOIN last child

I'm trying to do some custom filtering. I need to JOIN latest child post_author. This doesn't seem to work well, it keeps returning wrong childs: SELECT * FROM wp_posts LEFT JOIN ( SELECT ...
0
votes
0answers
66 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 ...
0
votes
0answers
111 views

Get post ID and custom taxonomy of posts that belongs to certain category, efficient by SQL?

I have a large Wordpress site with almost 200 000 "posts" (everyday is aded more than 2000 new) and sppecific homepage with about 30 loops to get last 5 posts from every category (sngle loop = single ...
1
vote
1answer
46 views

Custom Field Create Bulk via SQL Query

I have a question. A created a custom field named video_desc. I have ofer 2000 posts and I need to add this custom field to all posts and add the text "Description Here" to it. How can this be done ...
0
votes
2answers
279 views

How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code... global $wpdb; $findID = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = ...
0
votes
0answers
34 views

Move Content of Custom Field to Post Content

Hello everyone I have a custom field in all my posts - the field is _listing_additional_info This is on a custom post type called listings. I need to move the content of those custom fields into the ...
0
votes
1answer
50 views

Custom Fields Bulk Edit

I have a question. I am running detube theme which has a custom field named "dp_video_code" in which i put my video embeded code. Recently the embeded code has change and I need to modify the video ...
0
votes
0answers
223 views

$wpdb->get_results(…) returns empty array despite correct query

As title implies, I cannot seem to get $wpdb->get_results to give results. Running the "raw" query is successful, but this seems to be failing for some strange unknown reason. global $wpdb; ...
1
vote
1answer
103 views

Wordpress SQL query - returning 'true' 'false' or 'null'

I am working on coding a PHP form for my website that requires the user to enter a code before the form becomes active. I have a field called "used" that I set up as a Boolean/TinyInt which I thought ...
0
votes
1answer
40 views

How to order posts by the user_login that corresponds to a meta_value (which is a user id)?

I'm trying to create sortable column headers for a CPT list, but I'm stuck on one piece. When clicking on an "Assignee" column head, I want the list to display alphabetically by the login name of the ...
0
votes
1answer
48 views

Replace Unwanted Space in Post Content URL

I have a Wordpress site with a couple hundred posts. The posts were being created with batch processing and a piece of code was being inserted dynamically. I found an error in the URL of one of the ...
0
votes
0answers
58 views

trying to update post meta in bulk

I have been trying to arrange my site so that my URL structure is set to domain.com/collection/%collection%/%product-group% Where %collection% is a taxonomy term, collection is the index, and ...
0
votes
0answers
164 views

Change Login URL Without Plugin

I want to change the login url of my Wordpress install away from /wp-admin.php I am aiming to do so and am looking at changing the .htaccess file to add in: RewriteRule ^login$ ...
-1
votes
2answers
63 views

What's wrong with my $wpdb prepare

I can't get my head around this. I get this error: Parse error: syntax error, unexpected '"' in 224. The line is this between foreach $html: $html = ''; foreach ( $recent_across_network as $post ...
0
votes
0answers
41 views

Exclude posts from certain meta_key

I have query to retrieve all posts, but how can I check the condition for post meta_key ="develop" and meta_value='anything' SELECT DISTINCT date(p.post_date) as post_date FROM $wpdb->posts p ...
0
votes
0answers
24 views

How To Structure A Wordpress Database Query?

I have an array containing the IDs of the rows I want to update: $matches = array('abc123', 'def456', 'ghi789'); Rows with those IDs must be updated so that their 'confirmed' value is changed from ...
0
votes
1answer
51 views

wpdb getting avatars and author url

Running an SQL query to pull authors by votes they've received on posts. @bonger helped me out on my first post and helped me get this working great, but I created this new question since it's a ...
0
votes
1answer
177 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
145 views

$wpdb select date range of posts

0 down vote favorite Using this SQL query to sort users by how many votes(meta key) their posts have received. <?php global $wpdb; $results = ...
1
vote
1answer
82 views

Can't get result from sql using ajax result

I'm using an AJAX form to feed the code something to lookup in db. Separate table, not WP options. I'm getting the result from AJAX, but when I try to do the sql it just returns 0. This is the ...
0
votes
0answers
58 views

Can't Post to my Wordpress Anymore!

I'm at my rope's end with this whole thing and have tried everything I can to solve it. I have a WordPress site with a SQL database on Azure, but recently all of the users associated with the site ...