redirect pages with no content, instead of 404 error, using max_num_posts?

If the rest of your function works you just need to add a call to wp_safe_redirect and hook the whole thing into WordPress. I think that the first hook that will have a populated $wp_query is wp. So alter the last part of your function… if($max_page < $paged){ wp_safe_redirect(get_bloginof(‘url’),’301′); } And then add the following … Read more

JetPack Infinite Scroll not working on custom theme

Have you tried adding ‘type’ => ‘click’ under ‘footer’ => ‘page’, to see if the Jetpack works with click rather than the default scroll? It is also worth going to Settings -> Reading in the admin panel… does it say “To infinity and beyond….We’ve disabled this option for you since you have footer widgets in … Read more

Pagination not working

As I already stated in comments, you should never use query_posts, only use query_posts if you are intended to break your page functionalities. Add query_posts to the very top of your EVIL LIST. query_posts breaks the main query object, the very object that your pagination function relies on. Your pagination function relies on the $max_num_pages … Read more

Intentionally exceed max_num_pages on main query without getting 404?

On every page load, WordPress executes these functions in their respective order: init(); parse_request($query_args); send_headers(); query_posts(); handle_404(); register_globals(); where the main query is finished after query_posts(). Note that in this point in time, WordPress knows the template AND all the query variables like max_num_pages. In handle_404(), if the main query has any posts, the function … Read more

How to make my pagination loop continuously?

You could add an else to both ifs and get the first post/latest post: <?php $nextPost = get_next_post(); if($nextPost) { $nextPostID = $nextPost->ID; ?> <a class=”prev-post” href=”https://wordpress.stackexchange.com/questions/270728/<?php echo get_permalink( $nextPostID ); ?>”> <?php echo $nextPost->post_title; ?> </a> <?php } else { $first_post = get_posts( array( ‘posts_per_page’ => 1, ‘order’ => ‘ASC’ ) ); ?> <a … Read more