Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
- if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'sort-view-count' ) !== false ) {
- return array_merge( $query_args, array(
- 'meta_key' => 'post_views_count',
- 'orderby' => 'meta_value_num',
- 'order' => 'desc',
- ) );
- }
- return $query_args;
- }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment