-1
votes
0answers
24 views

Help analyzing var_dump [on hold]

I'm trying to debug a problem in a custom theme with the search.php page. I'm getting no results on what should be a good search. I added var_dump($wp_query->request,$wp_query->posts) to the top ...
0
votes
0answers
18 views

wordpress remove where clause in taxonomy page [on hold]

My site has installed woocommerce. When I visit taxonomy page, the below SQL is executed SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = ...
-1
votes
2answers
30 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
29 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
15 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
17 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
97 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
61 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
33 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
48 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
0answers
7 views

Getting duplicate rows in database through custom hardcoded signup page using Cimy User Extra Fields for autochimp sync

I have a custom coded sign up page where users fill in additional fields beyond the standard username and email. My end goal is to have these additional fields sync with my mailchimp mailing list. I ...
0
votes
1answer
14 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
22 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
78 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
53 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
19 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
42 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
40 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
65 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
35 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
74 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
47 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
31 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
90 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
29 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
33 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
30 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
59 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
52 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, ...
0
votes
1answer
26 views

Why this query is not showing any result on wordpresss home page?

I am learning wordpress database, And I have written this query for showing the data from the post table with id=2, but not showing anything. What is wrong with the following query? please help. ...
1
vote
2answers
459 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 ...
1
vote
2answers
49 views

Query that joins the postmeta table twice

I believe what I'm trying to do is too complex for the standard meta_query parameter in get_posts, so I'm trying to use a custom SQL query to do the following: I have a game custom post that has ...
0
votes
0answers
69 views

Would manually deleting the dumping data fix a “#1062 - Duplicate entry '1' for key 'PRIMARY'” phpMyAdmin error?

I'm new to PHP! I'm trying to import an SQL database file into myPhpAdmin for a WordPress I'm migrating, but I keep getting this error message: SQL query: `-- -- Dumping data for table ...
0
votes
1answer
47 views

phpMyAdmin displays error when importing database

I'm migrating a WordPress for a friend to a different server. I have already backed up all files and was given a copy of the database by the old server admin. The problem is that when I try and import ...
0
votes
1answer
43 views

Pre_Get_Posts order DESC not registering

I've created a filter function to filter a post type items by it's meta value _item_price. The problem is that it only works in Ascending Order and I'm not sure why. My pre_get_posts function looks ...
0
votes
1answer
41 views

Convert all dates in field to Unix time, except those already in Unix time

I have a meta field that is mixed with MM/dd/yy hh:mm dates and Unix timestamp dates. How do I convert all of the MM/dd/yy hh:mm dates in the db to Unix? I have only limited PHP and SQL knowledge so ...
0
votes
1answer
29 views

How to add data from wordpress tables to new database tables you have created

I'm just learning this database stuff and so I am a bit confused and was hoping someone could push me in the right direction. I have managed to create users in the wp_tables I have created in my ...
1
vote
1answer
27 views

How to find meta entries with their posts missing via SQL?

I'm looking to write an SQL query to do the following: Select all postmeta rows where the meta_value = a post id that does not exist. For example, postmeta meta_value may equal 235. Usually this ...
0
votes
1answer
65 views

How to set search query for joining two tables in sql?

What's the wrong with this query? SELECT l.company_name,DISTINCT c.sub_cat_name FROM tbl_listing l,tbl_sub_category c WHERE l.company_name LIKE '%cy%' and l.city_id='2' and l.area_id=23 ORDER BY ...
0
votes
1answer
235 views

$wpdb->prepare with ON DUPLICATE KEY UPDATE

I just took this code from $wpdb Codex page, and modified my existing Insert query: $table = $wpdb->prefix . 'user_req'; $post_id = explode('_', $_POST['post_id']); $user_id = $_POST['user_id']; ...
1
vote
0answers
40 views

Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin

I have a wordpress table like so (phpmyadmin and MySQL) | id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | ...
0
votes
0answers
108 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
0answers
91 views

Delete duplicate posts where meta_key is the same

I have imported some posts and this has caused some to be duplicated Each post (of a custom post type "property") should have a unique meta_key "import__id" value I need to delete all duplicate ...
0
votes
1answer
103 views

$wpdb->get_var - What value is returned when zero records are found?

I have the following code: $queryPermission = $wpdb->get_var( $wpdb->prepare("SELECT Active FROM testers WHERE user_id = '$user_id' ")); ...
0
votes
0answers
82 views

SQL query to remove first image in all posts

I've built a site up over a few years (3,500+ posts) where I've inserted images using the traditional method into the post content itself. I'm now moving to a different theme, and have made the first ...
0
votes
1answer
155 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
0
votes
1answer
122 views

Use wpdb->prepare for `order by` column name

In my current plugin, I am picking up the order by column as user input. So I thought of using wpdb->prepare to escape it. $wpdb->get_results($wpdb->prepare("Select id from $wpdb->posts ...
0
votes
1answer
45 views

Is there a WP function to get taxonomy name from taxonomy_term_id?

I need to get the taxonomy name from the taxonomy_term_id. I am currently using the following to get it: global $wpdb; $term_taxonomy_table = $wpdb->prefix . "term_taxonomy"; $taxonomy = ...
0
votes
1answer
49 views

Do I need to deal with WordPress SQL Injection

Do I need to prepare strings against MySQL Injection when inserting into the database using a WordPress comments function such as this: $data = array( 'comment_post_ID' => $post_id, ...
0
votes
1answer
52 views

SELECT from wp_users, get Displayname too

SELECT post_author, count(ID) as amount FROM dbold_posts WHERE WEEKOFYEAR( post_date ) = WEEKOFYEAR( NOW() ) AND post_status = 'publish' AND post_type = 'post' GROUP BY post_author ...