WP_PageNavi and WP_User_Query
-
Hi There,
I’m trying to get WP_PageNavi working with the new WP_User_Query. I have it working with a regular loop and I also am having some success with it on the User Query, but with some weirdness. Has anyone had success with this?
From looking at the core plugin code, it needs both the ‘number’ and ‘offset’ parameters from the query, but with any combination of including the values or not, I get varying degrees of failure.
I have 6 test users and use ‘number’ => 2 to display two per page. This works in that page navi show 3 pages and the first one has 2 users. The navigation somewhat works (showing in the url) but the users don’t change. With pagenavi normally, you use the ‘paged’ => get_query_var(‘paged’) option, but it doesn’t help here and doesn’t seem to be used by the plugin core which tries to calculate the value based on a combination of ‘number’ and ‘offset’. If I have ‘offset’, it offsets the users, but doesn’t correspond with working pagination…I still see the same 2 users, but now just numbers 3 and 4 instead of 1 and 2
global $alg_user_query; $alg_user_query = new WP_User_Query( // Get the users with our query array( 'orderby' => $algonquin_listusers_orderby, 'number' => 2, 'meta_query' => array( array( 'key' => 'profile_jobtitle', 'value' => '', 'compare' => '!=' ), ) ) ); $authors = $alg_user_query->get_results(); // Get the results if ( !empty( $authors ) ) { if ( function_exists( 'wp_pagenavi' ) ) { wp_pagenavi( array ( 'query' => $alg_user_query, 'type' => 'users' ) ); } // if function exists ?> <?php echo '<ul class="people_archive vcard">'; foreach ( $authors as $author ) { // loop trough each author $author_info = get_userdata( $author->ID ); // get all the user's data [...]
- The topic ‘WP_PageNavi and WP_User_Query’ is closed to new replies.