SQL select of users by metadata

Double-check your SQL syntax. It sounds like you want to do a JOIN … But you’re not building the query correctly. It should be something more like: SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM $wpdb->users u INNER JOIN $wpdb->usermeta m ON m.user_id = u.ID WHERE m.meta_key = ‘wp_capabilities’ AND m.meta_value LIKE ‘%supplier%’ ORDER BY u.user_registered You … Read more

wpdb get posts by taxonomy SQL

Sorry guys, I just found the solution: SELECT p.post_name, t.name as clientName FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON (‘p.ID’ = tr.object_id) INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id) WHERE p.post_status=”publish” AND p.post_type=”portfolio” AND tt.taxonomy = ‘clients’ ORDER BY p.post_date DESC … Read more

register_post_status – show_in_admin_all_list & show_in_admin_status_list does not affect query

TL;DR: It’s not a bug (as we generally understand it), rather it’s a feature that was never fully implemented in WordPress. Status of register_post_status() register_post_status() function was never fully implemented in WordPress. If you check WordPress Codex entry for register_post_status() function, you’ll see it’s clearly mentioned in a notice: NOTICE: This function does NOT add … Read more

Scanning Database for malicious Data

I’ve read that dumping the database as text and searching in it is a good way to go. You can search with phpmyadmin, but it’s limited. Depends on the size of the database and a good text editor, but you can delete post/page revisions before dumping the database to bring it down in size. Or … Read more

Using OR conditions in meta_query for query_posts argument

Use ‘relation’ => ‘OR’ as in the Codex example below: $args = array( ‘post_type’ => ‘product’, ‘meta_query’ => array( ‘relation’ => ‘OR’, /* <– here */ array( ‘key’ => ‘color’, ‘value’ => ‘blue’, ‘compare’ => ‘NOT LIKE’ ), array( ‘key’ => ‘price’, ‘value’ => array( 20, 100 ), ‘type’ => ‘numeric’, ‘compare’ => ‘BETWEEN’ ) … Read more

Add custom fields to search

please never do this: ‘value’ => $_GET[‘s’] … $query->get(‘s’);, get_search_query, or sanitize_key($_GET[‘s’]) are all safer options. Technically we shouldn’t be using get-params in wordpress at all, it’s not a best-practice. That get value could be all sorts of bad things, & we don’t want to pass it along to the db without making sure it’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)