Including ‘cat’ => $cat breaks meta_query

Not sure why this works, where the other query was failing. I’m not sure if it’s a bug that others are experiencing or not. Anytime I included any category “inclusive” arg, it broke my meta_query, but it didn’t seem to if i was “excluding” categories. So,…making an array of all category ids, then unsetting the … Read more

Time sort with meta_key using UNIX timestamp failing due to date differences

I will caveat this by saying that I am still not 100% sure I know what you are doing, but I believe the following will sort your results by time only assuming that your meta values are proper Unix timestamps. function orderby_time_only($orderby) { remove_action(‘posts_orderby’,’orderby_time_only’); return preg_replace(‘|(.*)\s(.*)|’,’DATE_FORMAT(FROM_UNIXTIME($1),”%k%i”) $2′,$orderby); } add_filter(‘posts_orderby’,’orderby_time_only’); $args = array( ‘post_type’ => ‘event’, … Read more

Passing conditional arrays to WP_Query() [closed]

Just build the static part of the args array, then add the conditional variables, then pass the args array to WP_Query(): // Static args $custom_query_args = array( /* static args here */ ); // Conditional arg if ( 1 == $promo ) { $custom_query_args[‘meta_query’] = array( /* meta query array */ ); } // Instantiate … Read more

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