Skip to content

Commit 7f7159a

Browse files
nacinrdworth
authored andcommitted
Add shim for querying by menu_order for <= version 3.4.
(cherry picked from commit a08bbae)
1 parent d994da8 commit 7f7159a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

mu-plugins/wordpress-shims.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/*
3+
* Plugin Name: WordPress Shims
4+
* Author: Nacin
5+
*/
6+
7+
// Add menu_order query variable for pre-3.5.
8+
if ( version_compare( $wp_version, '3.5-alpha', '<' ) ) :
9+
add_filter( 'posts_where_paged', function( $where, $query ) {
10+
global $wpdb;
11+
if ( $menu_order = absint( $query->get( 'menu_order' ) ) )
12+
$where .= " AND $wpdb->posts.menu_order = " . $menu_order;
13+
return $where;
14+
}, 10, 2 );
15+
endif;

0 commit comments

Comments
 (0)