How to validate WordPress generated password in DB using PHP?

Based on your other question … it sounds like you’re trying to validate a given plaintext password against what’s stored in the database. Here’s the function WordPress uses to do just that: function wp_check_password($password, $hash, $user_id = ”) { global $wp_hasher; // If the hash is still md5… if ( strlen($hash) <= 32 ) { … Read more

$wpdb->delete column values IN ARRAY()?

No, wpdb::delete does not handle anything other than WHERE field = X. You can just use the query method instead: $ids = implode( ‘,’, array_map( ‘absint’, $ids ) ); $wpdb->query( “DELETE FROM table_name WHERE ID IN($ids)” );

Optimize Multiple Taxonomy Term MySQL Query?

While this is really a MySQL question it does help to understand the WordPress SQL schema and also I love trying to optimize SQL queries so rather than send you off to StackOverflow I’ll try to answer you here. You may still want to post it over there to get some other opinions. And while … Read more

Slow wp_term_relationships query

Prepare yourself for an unsatisfying answer… After several days of testing, the conclusion that I’ve come to is that, put simply, this isn’t WordPress’ “fault”. I believe another related issue on the server was putting undue strain on the system. This was simply one of the slower queries, which, since the server was under strain, … Read more

find a random blogid across my multisite network that has at least one post published

An example that displays an admin notice listing a randomized array with all blog IDs, the result of a get_posts( array( ‘numberposts’ => 1 ) ) and marking the first one which get_posts result is different from zero. Result After refreshing: Code add_action( ‘admin_notices’, ‘wpse_60401_print_random_blog’ ); function wpse_60401_print_random_blog() { global $wpdb; $rows = $wpdb->get_results( $wpdb->prepare( … Read more

Check if post of title already exists

Yes $wpdb is built in and is loaded by the WordPress Core on every page load. I don’t see any critical problem with your code. I am going to suggest some improvements because I see some places where could go wrong, but mostly that should work. That makes me think that $article->heading is not matching … Read more