Order Query Loop By Custom Field with taxonomy
-
Hi, I tried below code from Order Query Loop By Custom Field
add_filter( ‘generateblocks_query_loop_args’, function( $query_args, $attributes ) {
// Apply filter if loop has class: order-by-priority
if ( ! is_admin() && ! empty( $attributes[‘className’] ) && strpos( $attributes[‘className’], ‘order-by-priority’ ) !== false ) {
// Add tag filter
$query_args = array_merge( $query_args, array(
‘meta_key’ => ‘priority’,
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘ASC’,
));
}
return $query_args;
}, 10, 2 );It works well but when I set query parameters to specific taxonomy in ‘Query Loop’ block, It shows nothing.
I’d like to show posts from specific tag, and I want posts to be shown with ‘priority’ meta key’s number order.
Any advice would be appreciate. Thanks.
- The topic ‘Order Query Loop By Custom Field with taxonomy’ is closed to new replies.