Skip to content
Advertisement

Tag: wordpress

WordPress Find ID of a Post with a specific meta value

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

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

Advertisement