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
19 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
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
2answers
588 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 ...
0
votes
1answer
29 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. ...
1
vote
1answer
849 views

How to Mass Delete Images from Media Library

I need your help. I am trying to mass delete attachments from a custom post type ('book') using a sql query. I found this snippet on the wordpress form: Wordpress.org I tested it on my local ...
0
votes
2answers
56 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 ...
-1
votes
0answers
31 views

How to select posts with categories by SQL select

Im trying to show some post from a specific category ( from a custom post type) by sql select, I manage to show all post by: <?php $post_date = get_the_date('Y-m-d'); $start_date = date("Y-m-01", ...
12
votes
3answers
20k 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
0answers
109 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
1k views

Export SQL query based on post type

I'm looking to export only wp_posts where post_type = post. Is that possible?
0
votes
1answer
26 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
30 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 ...
8
votes
6answers
37k 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
342 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
1answer
38 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
3k views

Overriding default calendar to show posts from a category

I'm trying to modify the default WP calendar (get_calendar()) so that it shows posts from a specific category and then use that as a shortcode. Here's what I've done: Copied across the ...
0
votes
1answer
79 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
24 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
23 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
46 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 ...
1
vote
3answers
2k views

How do I add indexes to Wordpress Database?

I got a message from Hostgator about my account being suspended because of the load it put on their servers. This is about the fifth time this has happened. I am on a shared server. And they said it ...
0
votes
1answer
298 views

SQL Bulk Move old posts by one author to another category

I'm looking to move a number of old posts by one author from one category to another category and was hoping someone could help me do this? I figure the easiest way would be through an SQL command? ...
0
votes
1answer
67 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
39 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
52 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
55 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 ...
3
votes
2answers
243 views

Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows: class ...
0
votes
2answers
181 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
16 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
46 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
86 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
26 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
149 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
25 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 ...
5
votes
5answers
8k views

Most efficient way to get posts with postmeta

I need to get a bunch of posts with their metadata. Of course you can't get metadata with a standard posts query, so you generally have to do a get_post_custom() for each post. I'm trying with one ...
0
votes
0answers
137 views

How to parse meta value from user specific post to google charts?

I'm currently working on a project where i need to visualize the progress of users (fitness). For that i have created a custom post type with custom fields. I want to parse the meta values associated ...
0
votes
1answer
38 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
136 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; ...
0
votes
1answer
34 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 ...
1
vote
1answer
83 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

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 ...
5
votes
3answers
7k views

How do you properly prepare a %LIKE% SQL statement?

I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input. SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%'; I've ...
3
votes
3answers
2k views

WPDB Insert or if exists Update

I'm not crazy familiar with WPDB or SQL in general but I have a custom table for my project and I'm trying to assign some metadata to it. What I'd "like" to happen is if a row exists, update it and if ...
0
votes
0answers
51 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
113 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$ ...
0
votes
0answers
23 views

How do I create a system to track logged in users' views each time an individual CPT post is viewed?

I have a custom post type created in a plugin I'm working on, using Piklist (as I have a lot of other things I can use it for in this project, in general). So my first step would be to create a table ...
-1
votes
2answers
53 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
40 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
21 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
154 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 ...