Custom Pagination is Broken

Chances are your pager is getting the count of all posts, regardless of whether they are published. In your query, you should add a filter for only published posts. $query_args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4, ‘paged’ => $paged, ‘post_status’ = ‘publish’, ); Then the results count and number of pager links should … Read more

Append URL query to next post link in custom query

Deep down that function uses get_pagenum_link(). This is filterable with the get_pagenum_link filter. So you could add and remove that filter that uses a global variable that gets set in your function before the link is retrieved: function wpse_287817_add_query_args( $url ) { global $wpse_287817_query_args; return add_query_arg( $wpse_287817_query_args, $url ); } add_filter( ‘get_pagenum_link’, ‘wpse_287817_add_query_args’, 10 ); … Read more

Why are my paginated posts always returning the same results?

Found the culprit. I’d foolishly hard-coded the offset to be 0, which must have been overriding WordPress’ query. I changed: $posts_list = new WP_Query([ ‘posts_per_page’ => 1, ‘offset’ => 0, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘suppress_filters’ => true, ‘paged’ => $paged ]); to: $posts_list = new WP_Query([ ‘posts_per_page’ => 1, ‘orderby’ … Read more

WordPress alphabetical A-Z custom post type post result display

Another option if you don’t want to hard-code the alphabet links (i.e., if no posts start with a letter, then that letter is not shown in pagination at all). // Always show pagination // First, grab all posts. $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘homeless’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ )); // … Read more

How to create pagination for users list using custom array?

<?php global $wp_query; $topuser = array(); $avatar_size = 100; $args = array( ‘role__in’ => array(‘contributor’, ‘author’), ‘hide_empty’ => ‘1’ ); $users = get_users( $args ); foreach ( $users as $user ) { $query = get_posts( array(‘author’ => $user->ID, ‘cat’ => ‘3’, ‘numberposts’ => -1, ‘post_type’ => ‘post’ )); $counter = 0; $post_count = count_user_posts( $user->ID … Read more

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.