How can I query all users who registered today?

Few months ago, I updated the Codex for get_users() and WP_User_Query, regarding the date_query support on the user’s registration date, in WordPress 4.1+. Then I also added a simple example on how to find users that registered during the last 12 hours. But the current question is how to find users that registered today. We … Read more

Fail to compare dates in meta_query

I have exact the same problem here, except i use the std. post type (post) and a category in my query. everything works except the sort order. $d = date(“Y-m-d”); $args = array( ‘post_type’ => ‘post’, ‘category_name’ => ‘events’, ‘post_status’ => ‘publish,draft,pending,future,private’, // just for me ‘meta_key’ => ‘event_start’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, … Read more

meta_query sorting by 2 keys

OK, the final workaround would be to split query: $sfp_query_args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘sfp_post_category’, ‘terms’ => $cat_id_arr ) ), ‘meta_key’ => ‘is_sponsored’, ‘post_type’ => ‘sfpposts’, ‘post_status’ => ‘publish’, ‘showposts’ => (int)$per_page, ‘paged’ => $paged ); …and use “posts_orderby” filter to modify ORDER part: add_filter( ‘posts_orderby’, ‘sfp_modify_orderby’ ); function sfp_modify_orderby( $orderby … Read more

How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?

Hopefully you’ve figured this out by now, but if you haven’t you should be able to use the “posts_orderby” filter to dial in a specific order for your query. I’m not going to give a full solution here, but you can refer to this post for more: http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/ EDIT: Here’s the Documentation – basically you … Read more

Sorting: custom query with orderby meta_value_num THEN by title

This is very crude but should sort your posts by year (meta_value) and then by title. It does depend on how the query is setup so it will only work with the query below or with similar ones. function alter_order_wpse_103181($order,$qry) { remove_filter(‘posts_orderby’,’alter_order’,1,2); $order = explode(‘,’,$order); $order = implode( ‘ ASC,’,$order); return $order; } add_filter(‘posts_orderby’,’alter_order_wpse_103181′,1,2); $q … Read more

Set Alias for meta_query arguments in get_posts()

Have a look at the meta_query_find_compatible_table_alias filter defined in wp-includes/class-wp-meta-query.php. This filter’s documentation: /** * Filters the table alias identified as compatible with the current clause. * * @since 4.1.0 * * @param string|bool $alias Table alias, or false if none was found. * @param array $clause First-order query clause. * @param array $parent_query Parent … Read more

Complex meta query with 3 keys

The culprit The culprit of the matter is meta queries not supporting different and/or nested relations – a shortcoming by the way, that has driven me nuts before as well. In a recent instance with a search scenario also. What you want to do simply cannot be accomplished with WP_Query as well as one loop … Read more

ORDER BY custom field value

You can create groups of meta_queries using specific compare operation on them, and since you want to order based in a single custom field, you can keep the order declaration dedicated to the single meta field. So: $q = new WP_Query( array( ‘meta_key’ => ‘population’, //setting the meta_key which will be used to order ‘orderby’ … Read more

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