Meta query with order by another custom field

After fiddling and searching a bit I managed to have: ‘selected’ 10 posts on top ‘remaining’ posts below sorted descending by date Unfortunately the ‘selected’ posts are in descending order … here is my query: $args = array( ‘post_type’ => array( ‘projekty’, ‘publikacje’, ‘wystawy’, ‘wyklady’ ), ‘post_status’ => array( ‘publish’ ), ‘meta_query’ => array( ‘relation’ … Read more

Display custom post type taxonomy and month

Do a simple meta_query and compare by meta_value_num. array( ‘post_type’ => ‘webcast’, ‘meta_key’ => ‘webcast-date’, ‘meta_value’ => array( time(), strtotime(‘+60 days’) ), ‘meta_type’ => ‘numeric’, ‘meta_compare’ => ‘BETWEEN’, ‘orderby ‘ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); For an easy example. You can find more complex examples on the site filed under meta-query – even more … Read more

meta_value_num sort glitch

You want natural order sorting, Example; $val = array(5.1, 5.11, 5.12, 5.2, 5.21); natsort($val); foreach ($val as $key => $val) { echo $val.”<br>”; } Produces: 5.1 5.2 5.11 5.12 5.21 Where as; $val = array(5.1, 5.11, 5.12, 5.2, 5.21); asort($val); foreach ($val as $key => $val) { echo $val.”<br>”; } Produces: 5.1 5.11 5.12 5.2 … Read more

Order by meta_key with two meta_queries

You can do this using WP_Query since 3.1 with a meta_query. $args = array( ‘meta_key’ => ‘_count-views_all’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $sortOrder, ‘posts_per_page’ => 9, ‘paged’ => $paged, ‘meta_query’ => array( ‘relation’ => ‘OR’ array( ‘key’ => ‘contributorid1’, ‘value’ => $id, ‘compare’ => ‘=’ ), array( ‘key’ => ‘contributorid2’, ‘value’ => $id, ‘compare’ => … Read more

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