I have about 25,000 posts here (and rising). All of them under a Custom Post Type “lead”. Each post has meta information, including a variable called “uniqid”. this uniqid is a url parameter. now i need the post id where exactly this uniqid exists. Now my question is if there is a way to speed up this determination. I have
Tag: wordpress
SQL – how to remove whole row if one of the column in subquery return NULL
I am stuck in 1 SQL query This query return 4 row ( As shown in the screenshot ) I want a scenario like : If subquery return NULL , then the whole row will not be shown. So in this example “childthree” should not be shown , as “parent_user_email” is NULL , so the whole 3rd row need to
If a meta_key has a meta_value, update the meta_key name
In a table called wp_postmeta, there are ~1K meta_key’s called _wcj_custom_product_tabs_content_local_1, but only ~100 have a meta_value. What I need to do is update the meta_key name, but only for the meta_key’s that actually have a meta_value. I can select all the meta_key’s that are not empty with this: But then how do I combine the query above with the
MYSQL: I want to update all rows in a table with values from another table where values from the first table are equal to the second
I am trying to update a damaged WordPress terms relation (in tables wp_terms and wp_term_relationships). Some tags were entered in Wordpress with their “term_id” number instead of their “name”, so instead of creating a relation with the original correct tag, a new tag was created with this number as its name. (For instance, if tag “toy” had term_id -> 2010,
SQL: how to copy value of meta_key inside array in another meta_key?
I’m asking here since seems more like a SQL question than WordPress. I have a WordPress installation using custom fields from a template and custom fields from a plugin (ACF). There are thousands of posts using the custom field from ACF, “subtitle”. Now I need to move all “subtitle” values to the other custom field, “td_subtitle”. I found a simple
Filter results by user role
I have a query that returns the total number of users per a specific meta value (gender), considering only users that are not blocked (user_blocked_access): I have to return only the results for a specific user role: But don’t know where I should adds this part of code. Answer You can add an additional JOIN: Note: This assumes that there
Is this code protected for SQL injection?
is this safe enough? Or should it be improved? Is this code protected for SQL injection? (PHP) Answer I take it for granted that $wpdb is from the WordPress project. Then as explained by the documentation, the very purpose of these placeholders is to prevent SQL injections. Hence you can consider your code safe against SQL injections. Personally I like
Get WooCommerce single products data from database with a SQL query
I am trying to get the raw data from the database for the woocommerce_single_product_summary in woocommerce. I need to use the data externally, but I cannot figure out how this is placed in the database, I can gather everything else I need with: Answer To get the correct desired meta keys from wp_postmeta table, you will have to look at
query monitor in wordpress shows slow query
I have a slow query on a wordpress site. I believe it’s my subquery inside it for the ‘abbreviation’. How can I rewrite this to make it faster? I’m not having much luck. The query takes about 0….
Get products with specific attribute term and specific category term in Woocommerce using SQL
I wish to find products with two different criteria. The code I used first to search one criteria is; This returns all those products (Object_ID) with the attribute “pa_1_scale” and ts.term_id = 400. I can also do this to return all products with product_cat and ts.term_id = 397, using a different WHERE statement UNION ALL just combines the two. How