Tagged Questions

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
23 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
35 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
40 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
13 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
17 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
37 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
61 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
26 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
39 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
32 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
106 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
15 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
38 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
62 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
20 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
83 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
22 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
29 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
74 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
63 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
32 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
32 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
38 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
95 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
46 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
36 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
20 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
31 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
140 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
111 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
66 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
54 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 ...
0
votes
1answer
28 views

how to insert missing tags into the posts through mySQL?

I am looking for a SQL query to insert a tag to multiple posts from a specific category. A pseudo query looks something like this: INSERT INTO POSTS VALUES TAG = "tagName" where Posts ...
0
votes
0answers
28 views

Backend menu that shows pages with specific page template and their child pages

I've set up a menu in the backend that shows a list of pages that have a specific page template assigned to them. I've managed to do this using the code below, but I also want to display the child ...
0
votes
1answer
425 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 ...
1
vote
2answers
72 views

Query that loads a custom type AND posts whose ids are not inside those custom types custom fields

On my news website I have posts and another custom type called "aggregato". This type has 10 custom fields, "link01", "link02"... "link10". Both posts and aggregato has a meta key, called "home", ...
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 ...
0
votes
2answers
67 views

How to add chunk of php, html, and sql code to variable an append to $content

I am creating a plugin (my first) which allows the site admin to display the most used post tags over the last X number of days. This plugin is an evolution of the WP Development question here - ...
0
votes
1answer
104 views

WordPress SQL query to tag all posts containing a specific word on title

Is there a way to bulk tag all posts which have for instance "bottle" in their titles? Thanks!
0
votes
0answers
161 views

SQL query for converting post meta image url to featured image

WordPress guru, we have a question: We work on a website, which was not updated a while. Most of time it have wordpress 3.2 installed. We've updated it to the latest wordpress version, but ...
0
votes
1answer
42 views

Which is better and faster ? Wordpress Queries or SQL Query

Suppose I am developing a minimal theme, the the post page single.php displays only the post title, the excerpt and the content. So in general that would be <?php the_title(); ?> <?php ...
0
votes
2answers
173 views

mySQL queries are executed twice on wordpress website

I'm sorry for my english. I'm trying to add some functionalities at my Wordpress website and to do this i have added a function in my function.php theme. The idea is to save in a custom table some ...
0
votes
1answer
127 views

How in insert image path in Wordpress database that will display product image in wp admin not on front end?

$insert = $wpdb->insert( $prefix."posts", array("post_title" => $posTitle,"post_content" => $postContent,"post_status" => "publish","post_type" =>"product")); // select products ID ...
0
votes
1answer
44 views

See output of a sql query while plugin installation in wordpress

Doing wordpress plugin development, I am creating a table (while installing the plugin) with the following string: $sql = "CREATE TABLE (query skipped)..."; /*someting*/ For example: I have this ...
1
vote
1answer
615 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
0answers
38 views

How to get list of posts with specific tag in separate category

I have a custom search function in my functions.php. And I need to change it, so that it will search also by tags in a specific post category (with ID 6 for example). For example someone search ...
0
votes
1answer
45 views

Slow query when joining wp_posts with a lookup-table?

I'm developing a map-based website and need to get posts associated with a place. Each place has a post in wp_posts and the other associated posts (images of each place etc) is associated with the ...
0
votes
1answer
59 views

SQL - Remove All The Users and Create A New User With Admin Role Via PhpMyAdmin

It is very easy to remove all the users and add a new user with administrative role via wp admin panel. But the requirement is to achieve this through SQL. I can trunc wp_users and wp_usermeta table ...
2
votes
1answer
87 views

How to update records using $wpdb?

I am migrating non-wp database to Wordpress (for the first time in my life, and hopefully the last). As both new and old websites are multilingual, one of the tasks for me is to connect the articles ...
0
votes
0answers
94 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, ...