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
40 views

Removing links from posts in WordPress

I have few blogs for some clients. I need to remove links to one of my clients blogs in all posts. Just to be clear I need to remove links and my keyword should stay like it is. I found this plugin, ...
0
votes
2answers
267 views

WPDB SQL query with prepare() returning variable, not db value

I have been trying to get this to work for awhile now and I cannot seem to get any farther on my own. It seems to work fine as a normal SQL query but not within the WP framework using prepare(). ...
0
votes
0answers
102 views

Wordpress on Microsoft SQL Server 2012?

I have a business requiremetn to host my Wordpress Server with a Microsoft SQL Server 2012 backend. I'm sure it's possible, but I don't quite know where to begin. Is this possible to implement without ...
-2
votes
1answer
2k 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
votes
1answer
505 views

How to remove in the wordpress database all posts revisions except the last three?

here is the commonly recommended sql command for removing posts revisions and cleaning up the wp database: DELETE a,b,c FROM `wp_posts` a LEFT JOIN `wp_term_relationships` b ON (a.ID = b.object_id) ...
0
votes
1answer
75 views

wpdb_prepare with multiple or condition

I want to execute a query like this: $wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string ); If I do the query with only one ...
0
votes
1answer
37 views

Extending the database

I'm trying to add an extra column to the comments database which will store the user ID of the post/page author. This is part of a plugin which will display new comments in reply to either a post or ...
0
votes
0answers
84 views

SQL Statement to sort custom query over multiple meta fields with duplicates?

i'm normally doing more Design/CSS stuff, so please be patient if this question is a nobrainer... My question is as follows: I have a custom post type, that has multiple custom fields. Now i need a ...
0
votes
2answers
134 views

How to use get_results() in widget front end?

I'm trying to get_results() in my widget's front end, this is my current code: public function widget( $args, $instance ) { echo $args['before_widget']; if($children = $wpdb->get_results( ...
0
votes
0answers
67 views

Line break issues with textarea in admin for Attachments

I am not sure if this is an issue with Wordpress, PHP or the Attachments Plugin. I am using the Attachments plugin to save attachments to a post with some meta information. One of which is a caption ...
0
votes
1answer
64 views

How to concatenate two separate colums into one?

In phpmyadmin I have two separate columns for latitude and longitude. e.g. lat: '38.897683' lng:'-77.03649'. These coordinates are generated for my location custom posts. How can I automatically ...
0
votes
1answer
101 views

query specific posts according their custom fields, using sql SELECT

My posts have a bunch of custom fields, to help insert and display custom info easily. I am trying to build a search that would select and display posts according values of specific 2 custom fields. ...
1
vote
1answer
90 views

posts_where Fails with More than One Custom Field in Query

Querying either of the 2 fields individually gives the expected result (posts are displayed). But, when both fields are included in the query (ex = 'foo' and 'bar' shown in below example), then no ...
1
vote
4answers
171 views

wordpress ajax relationship query

Using the relationship field from Advanced Custom Fields I link artists to events. Both these artist and events are custom post types. For each event, the post IDs of the related artists are stored in ...
0
votes
1answer
226 views

Query sql for truncate post_content in wp_posts table

Hello all i need remove all info in Wordpress posts content and i'ld like do it from phpmyadmin with a query. I need remove only the text and images from all posts content but not the entire post, so ...
0
votes
1answer
52 views

For a complete backup, is it enough to copy htdocs and export database?

I copied the htdocs via FTP from the server which hosts my wordpress blog. Moreover, I used phpMyAdmin to export the MySQL database. When I move to a new server, can I just create a database, run the ...
0
votes
1answer
169 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(); ...
2
votes
2answers
249 views

What is an efficient way to query based on post_meta?

The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a ...
0
votes
1answer
143 views

How to export database correctly for local to online

This process as a whole is fine... but I seem to have one small issue when I upload the database online. If I create a theme and modify some options that's fine for the local version. Once I upload ...
0
votes
1answer
38 views

Wordpress SQL - How to Check for Category?

I'm using the following SQL (wrapped in php) to find posts in a wordpress database: $sql = " SELECT p.* FROM {$wpdb->prefix}most_popular mp INNER JOIN ...
0
votes
1answer
115 views

SQL Query in WordPress - Getting Impossible WHERE error

I don't get any result in the SQL query below. I am trying to find user_id of users with custom usermeta fields. SELECT DISTINCT user_id FROM wp_usermeta WHERE ( ( ...
0
votes
0answers
47 views

Getting deleted users in database

I am using the database that is being used by a WordPress site. I am trying to get all the users from wp_users table with SQL query. But there is also previously deleted users in wp_users table. I ...
0
votes
2answers
1k views

Getting value from database table depending on field value

I am using a plugin called formidable which is similar to Gravity Forms in terms of purpose. I have two fields of interest. The first field loads up all the values in the Town column of my ...
0
votes
2answers
71 views

How can I order metaboxes in my posts in WordPress?

hello i did add a custem filed and this is my code add_action( 'add_meta_boxes', 'cd_meta_box_add' ); function cd_meta_box_add() { add_meta_box( 'my-meta-box-id', 'المعلومات الرئيسية لفلل مشروع', ...
2
votes
1answer
289 views

Bulk add tag (or any sort of label) to posts who have custom excerpt

The situation is the following: The blog as of now has 2200+ posts. In the beginning (2007/2008) I was using manual excerpts where I would put an image and a little bit of text. The manual excerpt ...
0
votes
1answer
53 views

Advanced search: roles and multiple taxonomies

I have a site with custom roles, and custom taxonomies. I'm making the advanced search, where custom posts can be filtered by roles and taxonomies. To accomplish this, I'm using my own custom SQL ...
-1
votes
1answer
173 views

SQL query to check whether a meta key is set or not for a post in post_meta table

Condition: some post have meta_key 'status'. Please help me in with this condition: sql query for those post who don't have meta_key 'status'
0
votes
1answer
99 views

An action hook where a comment meta is updated

By analogy to the hook on post meta update, I use the following code for hooking when comment meta value is updated. My comment meta key is "consider" and can have 2 values: 0 and 1. My Goal is to ...
0
votes
1answer
227 views

SQL: Select wordpress posts with given text string and add a custom field to them?

I want to select all wordpress posts that have a certain text string. Then to add a custom field to all those posts. Here is what I figured out so far but it doesn't work INSERT INTO wp_postmeta ...
0
votes
2answers
119 views

count number of user comments with a specific comment meta value

I am using the code below to count the number of comments by a certain user: global $wpdb; $count = $wpdb->get_var( 'SELECT COUNT( comment_id ) FROM '. $wpdb->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
1answer
2k views

Using OR conditions in meta_query for query_posts argument

I have searched high and low for this but I cant seem to locate anything. I am trying to filter some results and when I make an args array like this and pass it to query_posts I noticed that the ...
0
votes
2answers
107 views

Which query method to use? (edit- wpdb syntax problems)

I am trying to create a query in order to get all the metadata from a custom post type named match_reports that is associated with a meta_key and meta_value in another custom post type named ...
0
votes
1answer
47 views

post id not displaying

I have used this code in header.php ### get the author info global $current_user; get_currentuserinfo(); $authorid = $current_user->ID; ### get the last post id using author id ...
-1
votes
1answer
379 views

SQL query add only posts with custom field to array

I have this SQL query which is building an array of wordpress posts... $query = "select $wpdb->posts.* from $wpdb->posts,$wpdb->terms,$wpdb->term_taxonomy,$wpdb->term_relationships ...
0
votes
1answer
298 views

SQL Query to select post title & post ID from a particular category

I am looking for SQL query to select post title & post ID from a particular category. I looked at wordpress table structure but it is really confusing me.
0
votes
1answer
86 views

Custom Wordpress SQL Query 4 posts per custom taxonomy

I'm currently developing a Wordpress website that has a large navigation that lists the 4 most recent posts within a hierarchical taxonomy. I dont have any experience with $wpdb, but it seems like ...
0
votes
1answer
52 views

count number of all comments by a user on different (non-repeated) posts

I thank you in advance for your help. I am using Wordpress for about 2 years, but always avoiding SQL inside my scripts and looking for built-in functions to perform my goals. To count the comments ...
0
votes
0answers
77 views

Ranking authors by post meta value

I have custom post-type with custom post-meta and i want to rank authors by post meta value.I can show the SUM of a meta value on author page with this code <? php $points = ...
1
vote
2answers
559 views

Optional Meta Query

I have places stored as posts in WP's posts table. I am doing some geo-locating using Geo Data Store (http://wordpress.org/plugins/geo-data-store/). This is working great for me, as I can currently ...
0
votes
1answer
528 views

WP_Query with several meta_query-statements and order by meta_value

This is my query: $the_query = new WP_Query( array ( 'post_type' => 'pass', 'posts_per_page' => '-1', 'post_status' => 'publish', ...
0
votes
2answers
115 views

making php value numeric

I used some of this code from this page on Stack Overflow: Using wp_query is it possible to orderby taxonomy? It's about the function to be able to sort a query by a taxonomy value. Although it works ...
0
votes
1answer
144 views

wpdb prepare sql problem

I have problem with wpdb prepare and sql query. If i run the query directly thru wpdb->get_results it's working fine. Here it is: $alabala_sql = $wpdb->prepare( " SELECT * FROM ...
6
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
780 views

Up/Down voting system for Wordpress

Looking in all posts with keywords "voting system, upvote, downvote", I can't find a satisfying solution for this issue, except accepting one of the available plugins, spend a lot of time undersanding ...
0
votes
1answer
215 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? ...
-1
votes
1answer
317 views

SQL query to return categories and category parents

I have some categories which are not correctly defined. I.e. their parents are messed up. How can I select with SQL all categories and their parents?
0
votes
2answers
71 views

How can I get all author written content?

I have a site that needs two different tabs: 1. all author written content (Posts, comments, CTP) 2. all author followed content (categories, taxonomies, other users content) For the first all I ...
1
vote
0answers
184 views

Get posts under a category with SQL

How can I retrieve posts under a category with plain SQL with out using WordPress native api's like get_pages? My Wordpress table wp_terms contains a term named Restaurants. I want to list the post ...
0
votes
1answer
305 views

Export all posts to import as product items

Up until now, my client has been using WordPress posts as his way to display his products. I now need to export all these posts into a CSV format so that I can format the CSV file and import it back ...