Sorting a custom post type in pre_get_posts

You can add a filter on posts_clauses to; left join additional columns for each meta filter add order by clause base on those column values. Something like below should work, assuming your meta key is start_date and the value has the actual date format Y-m-d and your post type is talks add_filter( ‘posts_clauses’, function ($clauses, … Read more

User Query Multiple Orderby Clause

Try using: ‘orderby’=>’distribution_list last_name’, ‘order’=>’ASC’ Instead of: ‘orderby’ => array( ‘distribution_list’ => ‘ASC’, ‘last_name’ => ‘ASC’, ), So: $users = new WP_User_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘lastname’ => array( ‘key’ => ‘last_name’, ‘compare’ => ‘EXISTS’, ‘type’ => ‘CHAR’, ), ‘list’ => array( ‘distribution_list’ => array( ‘key’ => ‘distribution_list’, ‘value’ => ‘”72″‘, ‘compare’ … Read more

Query Multiple Filters, one with Meta

Okay, I muddled around until I found what I feel is the best solution. Please feel free to offer any constructive criticism. I concluded this was not possible with a single query, so I broke it into two queries. The basic idea is to get all items matching each query, loop them to build an … Read more

How do I find users by password?

The user password (stored as an MD5 hash) can be retrieved like so: $users = get_users(); foreach ( $users as $user ) { $password = $user->user_pass; } Assuming you have some known value for passkey, you can hash it and compare it to each user’s password: $passkey = ‘somestring’; $hashed_passkey = md5( $passkey ); $users … Read more

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