How to fix pagination for custom loops?

The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you create … Read more

Display Authors in a grid loop

Definitely over thinking it <div class=”section group”> <?php printf(‘<h1>%s</h1>’, the_title()); foreach($users as $user) { ?> <div class=”author”> <div class=”col span_1_of_3″> <div class=”authorAvatar”> <?php echo get_avatar( $user->user_email, ‘128’ ); ?> </div> <div class=”authorInfo”> <h2 class=”authorName”><?php echo $user->display_name; ?></h2> </div> </div> </div> <?php } ?> </div>

Alter query using pre_get_posts() if meta_key is present

Based on data from your Gist, the following pre_get_posts condition should work to limit your posts per page. add_action( ‘pre_get_posts’, ‘my_set_category_posts_per_page’ ); function my_set_category_posts_per_page() { global $wp_query; if ( ‘category_sticky_post’ === $wp_query->query_vars[‘meta_key’] ) { $wp_query->set( ‘posts_per_page’, 8 ); } }

Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?

Updated answer: The default behavior of WP is exactly what you want. The problem is that you are using get_posts() which completely ignores the sticky post behavior by forcing ignore_sticky_posts = true (check the source). So you need only one query, just use WP_Query(): $postsList = new WP_Query([ ‘post_type’ => ‘post’, ‘posts_per_page’ => $default_posts_per_page, ‘paged’ … Read more