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)

1
vote
1answer
116 views

Get the timout value of a saved transient?

Does anyone know if there is a Wordpress function to get the timeout value of a saved transient? I am using a transient with a 5 minute timeout to cache data from a web API call locally. Between ...
3
votes
2answers
3k views

Retrieving custom fields with $wpdb->get_results

I'm trying to use $wpdb->get_results to retrieve an array of all posts including custom fields. I can retrieve the meta_key and meta_value columns like this: [meta_key] => state [meta_value] ...
0
votes
2answers
288 views

Fetching review value using wpdb class

I'm generating an XML file using PHP for a website where they review tech products. In the XML file, I have to display the rating of products. For rating purposes, I'm using GD Star Rating plugin. ...
1
vote
1answer
160 views

$wpdb get_var issue

I've been at this for while, but can't figure out why the below isn't working. I have my date saved as a 'MM/DD/YYYY' string. global $wpdb; $new_day = $day->format("m/d/Y"); $qty = ...
0
votes
1answer
426 views

Remove password protection from all posts

So I messed up my blog (QBobble). I had an SQL backup, fortunately, so I reinstalled Wordpress, and imported my SQL database. Unfortunately, it password protected all of my posts. I know that I can ...
3
votes
1answer
167 views

How should I intercept the main query and inject custom join / order by / group by criteria

I have a CPT that is a member of two separate taxonomies. On the taxonomy archive page for one of the taxonomies, I need to further group and sort on the second taxonomy like so: ...
2
votes
2answers
379 views

Moving database with phpMyAdmin

I have a remote (website) version of a wordpress site and it's got more recent information than my local (computer) version. I would like to move the data over to my local using phpMyAdmin, what is ...
0
votes
1answer
43 views

How to migrate a database from a server to another

I try the export method of phpmyadmin, but the user is exported with the data... so there is no way to re import it into another database without error message. The old user is name : ...
0
votes
1answer
95 views

Proper approach to moving complete site from one domain to another AND preserve widgets

I consider myself fairly versed in this matter, however I've recently had a rash of issues when moving sites. I am able to successfully move the site, edit wp-config.php, move the database, etc. ...
0
votes
2answers
352 views

Get comments after specific date

I don't think this is a parameter in get_comments( $args ); so I'm using a SQL statement. First I obtain a comment date from a separate table I created. Afterwards, I want to retrieve all comments ...
1
vote
2answers
2k views

Export entries and multiple custom field meta to .csv?

First time poster. I'm trying to export a bunch of custom posts out to a csv file so I can easily import them into a new database. I've ran the native export to xml, but it's not the correct format I ...
1
vote
0answers
277 views

Why is my 'list_terms_exclusions' filter function timing out? [closed]

Why is my function timing out? When the issue was first noticed I added wp_defer_term_counting('true') to delay that process but to no avail. /* Filter category from get_categories and ...
0
votes
1answer
46 views

Removing posts by sql

Often i build a site and we have test posts. I was wondering if there's a way via sql to drop all the blog posts with a simple sql query. Obviously, I would have backed up my previous database before ...
0
votes
3answers
129 views

quotes problem in very simple sql

I just simply want to execute a SQL sentence inside of a post (i am using EXEC-PHP widget for that). The problem are the quotes when i want to do something like $my_name='hello' "select * from ...
0
votes
1answer
62 views

Exporting by table

I am using PHPmyAdmin to move a site. My site is too large to use the single file export/import method. (I know how to do it, it works fine on smaller sites.) It seems the only thing working for me ...
0
votes
1answer
73 views

How can I get posts from 9/13/11 to today with SQL? [closed]

I have been working with a client to redesign his site and we are at the stage where we are going live, except I'm running into a little problem. Time is of the essence, as the deadline is mid-day ...
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?
3
votes
4answers
7k 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 ...
1
vote
1answer
242 views

Location-Based Pages displaying results near customer

I'm creating a website where the customer will enter their postal code and the pages (with a distance selected of 5, 10, 20 miles) will display on either a Google map or Bing map. The page results ...
0
votes
2answers
162 views

Assign a list of categories with a parent category

I imported hundreds of locations and other categories. Now I have a list of locations in categories to which I would like to assign the "Location" category as its parent. I have tried sql but the ...
1
vote
1answer
2k views

Add Admin User via SQL

I gave my client the admin account to his wordpress install and I forgot to add an administrator user for myself. Now, I can no longer access the admin panel because they have changed their password. ...
2
votes
1answer
246 views

Multipart/formatted MySQL query problem

I'm creating a plugin and I want to automate the creation of a MySQL Trigger on a table. The problem seems to be that $wpdb->query doesn't appear to accept either multipart statements and/or formatted ...
1
vote
1answer
716 views

Preferred Method of debugging a wordpress SQL calls?

What is your preferred method of debugging Wordpress Applications when writing custom behind-the-scenes SQL calls, etc. ? Coming from a Rails background, I usually tail a log file that displays not ...
0
votes
2answers
318 views

Wordpress Categories: Function using custom SQL to return array of specific category IDs

I'm developing a custom theme which uses categories for positioning, all of which begin with an underscore (e.g. _position1). I have an SQL query as below to get a list of these categories (those ...
0
votes
2answers
418 views

wordpress sql posts query won't display the latest post in a specific category

Hi I tried to display 5 posts titles from a specific category also show the date, but it won't display the most recent one that just published, I had to change the recent post date 2 months so it'd ...
1
vote
4answers
310 views

Retrieving a Value from a wp-database

why my sql statement is not returning any value.. is this wrong? <?php global $wpdb; $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ...
1
vote
2answers
1k views

How to rename a custom field?

I have 3000 posts with that custom field name 'refer' and i need to change it to 'ref' for theme needs, instead of doing it manually i need a query or technique to change them all. Question 1 I am ...
0
votes
2answers
2k views

SQL select of users by metadata

Hi I'm trying to select users with a particular role only, using the following sql statement... SELECT DISTINCT ID, u.user_login, u.user_nicename, u.user_email FROM wp_users u, wp_usermeta m WHERE ...
0
votes
2answers
987 views

export individual posts to text files or a single csv file

I'd like to export my blog posts to plain text files so I can version control and update them using emacs org-mode via the org2blog package. However, I'm unfamiliar with SQL and the wordpress ...
2
votes
2answers
4k views

What's the easiest way to duplicate an entire navigation menu?

What's the easiest way to duplicate an entire navigation menu? I don't care if it involves SQL commands or whatnot. I just have some really big menus that I'd like to duplicate. Didn't see a plugin to ...
0
votes
2answers
381 views

Display latest post from Wordpress Featured Category that is also in X,Y,or Z categories

I want to display the latest post from a "featured" category (id=1) that may also be in either X category, Y category, or Z category (id=2,3,4 respectively). Note, there are other posts in categories ...
3
votes
2answers
2k views

SQL query to extract only the “current” wp_posts?

The wp_posts table seems to retain all revisions of the same, ok very similar but presumably different, posts/pages/whatever. I'm somewhat conversant with SQL but not WordPress. I need to extract ...
3
votes
2answers
738 views

Display only certain posts based on visitor's country?

Is it theoretically possible to have the following feature? Each post has a country code. When a visitor comes in, the system will determine the visitor's country code. Then when the page renders, ...
2
votes
2answers
2k views

How to set up default values for a plugin?

What is the best way to go about setting up default values for a plugin? Should I just insert those values into the wp_options table? AND...if that's the best way to go about it, I have another ...
7
votes
1answer
3k views

Making my plugin multi-site compatible

I want my plugin to be installed on each blog and create database tables per blog. I have this code: register_activation_hook( __FILE__, 'install1' ); function install1() { global $wpdb; if ...
0
votes
2answers
338 views

Moving an entire wordpress site from one domain to a new domain and database

I have done all the steps requiered to import the dump.sql file to new database, and copiey the entire content from the old domain over to the new one. When i login to mydomain/wp-admin, i'm ...
2
votes
2answers
2k views

Import old SQL dump into new Wordpress version

I'm trying to restore a Wordpress blog from a backup. Unfortunately, all I have is an SQL dump of the database as generated by phpMyAdmin. The dump was created when the blog was running Wordpress ...
2
votes
2answers
2k views

Improving WP_Query performance for multiple taxonomies

I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I'm using a WP_Query like so: ...
0
votes
1answer
175 views

How to export 2 week's worth of posts

I need to export the last two week's worth of blog posts from one site into another site, including all meta data and post author info. Is there a good SQL statement to do this, or a plugin that ...
1
vote
1answer
448 views

Importing Geo data into wordpress database

I have a listing wordpress site and want to integrate geo data into the Wordpress MySQL Database for custom search functionality I want to utilize different aspects to create different things... ...
2
votes
3answers
5k views

Pagination with custom SQL query

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working ...
0
votes
1answer
782 views

How to retrieve sticky post in raw sql?

How I could made a sql query who retrieve all the sticky post in a wordpress database? This is because we use a new app over the old wordpress website database, and I don't know where Wordpress ...
2
votes
2answers
950 views

How to add SQL file with PHP to WordPress database [closed]

I have SQL file with US zip codes (over 41000 lines of code). I want make a plugin that inserts this SQL file into WP database so user can do a search by zip codes. I want to insert SQL with PHP ...
2
votes
2answers
167 views

How can I get a list of plugins and which blogs are using them?

I'm about to upgrade my Wordpress MU installation to wordpress 3 Before I update, I want to find out which blogs use which plugins. I don't see a way to do that in the UI, is there? What about a ...
2
votes
1answer
763 views

orphaned taxonomy terms remove by sql query

I have 3 custom post types each of these CPT's have posts that are set to auto delete via a given time scale by cron jobs, thing is when they are deleted it leaves behind orphaned taxonomy terms in ...
0
votes
1answer
421 views

Speeding SQL queries for a large database?

I am using a WordPress plugin called feedwordpress in order to run a planet like website on wordpress (See it here). The plugin is great except for one thing - it hogs down my (VPS) server into ...
9
votes
2answers
17k 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
224 views

How can I convert everything from category X to have post format Link

My "links" come in from Windows Live Writer, from a perl based delicious sync directly to the database and who knows where from. They all have in common that the category is 'Daily-Links'. So I think ...
2
votes
1answer
374 views

get posts and postmetas in assoc array

how do I get all posts and postmetas in an associative array? $allposts = $wpdb->get_results(" SELECT $wpdb->posts.post_title, $wpdb->postmeta.meta_key FROM $wpdb->posts JOIN ...
1
vote
1answer
279 views

Detect session/cookie variable in wordpress to prevent access to documents

<?php @session_start(); If (!array_key_exists(‘authed’, $_SESSION)) { include ‘not_authed.inc’; exit(); } // go about your business. ?> and i'm trying to add that to this: ...