Pagination doesn’t function properly for archive of a custom post type set as the front page

Between my phone and work some errors creeped in, sorry about that. here is my revised answer. Hope this helps in solving your problem. PROBLEM 1 You should not name your template ‘archive-{$post_type}.php’ if it is a page template. This totally goes against the template hierarchy for pages, and that is why your static frontpage … Read more

How to use custom previous/next link ?

Do this to output only links for previous and next pages: <?php previous_posts_link ( ‘Previous’ ) ?> <?php next_posts_link ( ‘Next’ ); ?> Then add filters to your functions.php to add a class to each link: function next_posts_link_css ( $content ) { return ‘class=”next”‘; } add_filter( ‘next_posts_link_attributes’, ‘next_posts_link_css’ ); function previous_posts_link_css ( $content ) { … Read more

Pagination is not working with custom query inside a homepage template

I finally made it work. Leaving the answer here in case someone else have the same problem. <div id=”content”> <?php global $paged; global $new_query; $paged = get_query_var(‘page’); query_posts( array( ‘cat’ => 251, ‘paged’ => $paged ) ); $new_query = new WP_Query(); $new_query->query(‘cat=251&posts_per_page=3&paged=’.$paged); ?> <?php while ($new_query->have_posts()) : $new_query->the_post(); ?> <?php the_title(); ?> <?php endwhile; ?> … Read more

How to exclude or filter password protected posts when using next_post_link() previous_post_link

The function next_post_link() allow excludes, with the parameter excluded_terms. Add a list of the IDs of the password protected posts to this param. You get a list of all password protected posts with the follow example via DB select. $password_pages = $wpdb->get_col(“SELECT ID FROM $wpdb->posts WHERE post_status=”publish” AND post_type=”post” AND post_password !=””); Alternative can you … Read more

new WP_Query messes up pagination

If I understand you correctly you just want to display a different amount of posts at archives, for this you don’t need a custom secondary query at all. You can control it via pre_get_posts hook, either making use of posts_per_page or posts_per_archive_page parameter. Example for pre_get_posts function wpse188786_different_number_of_posts_for_archive_ppp( $query ) { if ( !is_admin() && … Read more

How to show 1-5 of X Total Results

it’s been a long time, I had exact the same task and here is the solution $from = ($query->query_vars[‘posts_per_page’] * $paged) – ($query->query_vars[‘posts_per_page’] – 1); if(($query->query_vars[‘posts_per_page’] * $paged) <= ($query->found_posts)){ $to = ($query->query_vars[‘posts_per_page’] * $paged); }else{ $to = $query->found_posts; } if($from == $to){ $from_to = $from; }else{ $from_to = $from.’ – ‘.$to; } It’s not … Read more

Pagination on Custom Post

When you use WP_Query to get post from database, you must have to use next_posts_link() with max_num_pages parameter for our current query. You can do this as below. <?php next_posts_link(‘More &raquo;’, $packages->max_num_pages) ?> Now your code will become this. I have made above changes in following code. <div class=”eight columns”> <ul> <?php $paged = (get_query_var(‘paged’)) … 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.