WP_Query with tax_query, order by most ‘matches’
WP_Query with tax_query, order by most ‘matches’
WP_Query with tax_query, order by most ‘matches’
You could use tax_query to get only the posts with the term that is currently being looped. $argsPost = [ ‘post_type’ => ‘meal’,//CPT meal ‘posts_per_page’ => -1, ‘meta_key’ => ‘ordre’, ‘orderby’ => ‘meta_value’, // Use the custom post order ‘order’ => ‘ASC’ ‘tax_query’ => array( array( ‘taxonomy’ => ‘cat_meal’, ‘field’ => ‘term_id’, ‘terms’ => $term->term_id, … Read more
Woocommerce change tax rate programmaticly
Now I am able to sort taxonomy terms by term_order using below snippets. But I am still seeking answer for the original question “How to do it using pre_get_terms”. function foo_tax_order($orderby, $args){ return ‘t.term_order’; } add_filter(‘get_terms_orderby’, ‘foo_tax_order’, 10, 2);
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
Simply go to Settings > Discussion > Other comment settings > then look for the pull-down menu that will let you reverse the order. As per this video: https://premium.wpmudev.org/blog/wp-content/uploads/2014/01/New-comments-first.webm
adding this in the functions.php file works. Just remember to re-save your permalinks & empty the cache a few times to see the changes. add_action( ‘init’, ‘wpse13483_init’ ); function wpse13483_init() { add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=asc’, ‘top’ ); add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)/order/([^/]+)?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=$matches[3]’, ‘top’ ); // with pagination; add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)/order/([^/]+)/page/([0-9]{1,})?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=$matches[3]&paged=$matches[4]’, ‘top’ ); }
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
The following query works. Note the quotes in AND blog_id != ‘1’ global $wpdb; $query = ” SELECT blog_id FROM $wpdb->blogs WHERE site_id = %d AND public=”1″ AND archived = ‘0’ AND mature=”0″ AND spam = ‘0’ AND deleted = ‘0’ AND blog_id != ‘1’ ORDER BY blog_id ASC”; $blogs = $wpdb->get_col( $wpdb->prepare( $query, $wpdb->siteid) … Read more
As for the edit (leading zeroes): /* will print “001” */ echo sprintf( “%03d”, 1 ); /* will print “00097” */ echo sprintf( “%05d”, 97 ); As for the inital problem: Obviously, I believe your problem description, but if ‘orderby’ => ‘meta_value’ does not produce duplicate results, neither should a change to ‘orderby’ => ‘meta_value_num’. … Read more