Skip to content

Commit

Permalink
set posts_per_page to -1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Oct 2, 2023
1 parent d34a596 commit 1073914
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion simple-page-ordering.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,26 @@ public static function load_edit_screen() {
'sort_by_order_link',
)
);
add_action( 'pre_get_posts', array( __CLASS__, 'filter_query' ) );
add_action( 'wp', array( __CLASS__, 'wp' ) );
add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
}

/**
* This is to enable pagination.
*
* @param WP_Query $query The WP_Query instance (passed by reference).
*/
public static function filter_query( $query ) {
$is_simple_page_ordering = isset( $_GET['id'] ) ? 'simple-page-ordering' === sanitize_text_field( wp_unslash( $_GET['id'] ) ) : false;

if ( ! $is_simple_page_ordering ) {
return;
}

$query->set( 'posts_per_page', -1 );
}

/**
* when we load up our posts query, if we're actually sorting by menu order, initialize sorting scripts
*/
Expand Down Expand Up @@ -524,8 +540,9 @@ public static function sort_by_order_link( $views ) {
$class = ( get_query_var( 'orderby' ) === 'menu_order title' ) ? 'current' : '';
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
if ( ! is_post_type_hierarchical( get_post_type() ) ) {
$query_string = add_query_arg( 'orderby', 'menu_order post_title', $query_string );
$query_string = add_query_arg( 'orderby', 'menu_order title', $query_string );
$query_string = add_query_arg( 'order', 'asc', $query_string );
$query_string = add_query_arg( 'id', 'simple-page-ordering', $query_string );
}
$views['byorder'] = sprintf( '<a href="%s" class="%s">%s</a>', esc_url( $query_string ), $class, __( 'Sort by Order', 'simple-page-ordering' ) );

Expand Down

0 comments on commit 1073914

Please sign in to comment.