WP_Query docs gives a warning about the offset parameter: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination.
Try something like this:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$newsArticles = new WP_Query(array(
'posts_per_page' => 16,
'post_type'=> 'news',
'paged' => $paged,
));
while( $newsArticles->have_posts()){
$newsArticles->the_post(); ?>
// HTML
<?php } ?>
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $newsArticles->max_num_pages
) );
See more examples of paginate_links here:
Related Posts:
- pagination not working for category.php (custom post types in categories)
- Custom post type pagination error
- Fourth page of custom post type archive page does not exist
- Query Multiple Post Types and Paginate Newly Created List
- Display all posts in a custom post type, grouped by a custom taxonomy
- How to use a custom post type as front page?
- Display several random posts, but make sure a condition is met
- Number of pages – multiple (custom) post types
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Retrieving 3 latest post from each of 5 different custom post types
- Pagination Doesn’t Work
- Numeric pagination custom post type
- Posts in Multiple Columns and Rows with one single loop
- Newer/Older posts links display same posts on every page
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- Fix custom query pagination without changing site-wide posts-per-page settings
- Query Custom Post by Category
- Pagination not working
- Pagination Issue: Custom Post Type In Index
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Loop on front-page.php
- Unable to get paginate_links working with a custom query [duplicate]
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Loop through Custom Post Type, and then show children within each iteration
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Can I create a loop with multiple post types and specify different $args for each post type?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Pagination on a custom post type loop
- WP_Query orderby modified to include custom meta changes
- How to make sure content doesn’t display if selection is empty
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Previous/Next Link by Meta Value in CPT
- Paging doesn’t work?
- Custom taxonomy rewrite give pagination 404
- What’s the WP way to load remaining custom posts?
- How do you paginate a query grouped by month?
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- can these 3 queries be re-written as 1 query?
- Wrapping x posts in html without leaving empty html
- WP Query post__in not returning correct results
- Sort posts in loop by the WooCommerce Membership of the author
- Pagination Error : Duplicate argument being outputted
- Custon Content within WordPress Loop
- Loop increase number
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- get_pagination not working on a custom post type query (using WP_Query)
- WP_Query with custom post type ID
- display posts of custom post type with custom taxonomy
- Custom post type and custom taxonomy 404 on page 2
- postsperpage value not being applied
- Pagination for search results of custom post type [duplicate]
- Display the current post in browser as the first post in a loop (for a slideshow)
- foreach loop inside the loop creating duplicates in output
- All blog posts are not showing up
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Single parent post lists child posts with pagination
- How do I list a custom field and custom taxonomies for each result in a loop?
- Custom Post Type, Pagination and 404s?
- What is the most efficient way to execute recursive complex queries?
- custom taxonomy pagination 404 error
- Pagination in custom post type archive.php not working
- Pagination not working in custom post type. Help
- Numeric pagination custom post type
- Problems in paginate_links with custom query loop and MB-Relationships
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Make pagination work as a carousel (custom query)
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- subtracting the current post form then whole loop, which is generating all CPT titles
- sorting in wp query based on custom field value
- Custom post Query and WordPress Post Query Clash
- WordPress loop add heading before first of type
- Only show current category post
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- Is it possible to add query parameters on the archive page?
- Loop with Custom Post Type and Taxonomies
- Custom post type archive pagination with HTML5Blank theme?
- How can I pull information from my loop and divide them seperately?
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- Pagination not working with custom loop
- Fallback if statement based on the number filtered from it
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working on homepage
- send user to first page of results when reposting to page?
- Pagination broke after updateto WordPress 3.4 [duplicate]
- Catergory args causing loop not to show
- Unable to display paging navigation with a custom post type loop
- How to insert a post from a different post type after every nth post
- Complex Custom Loop with Includes
- “Page not found” while on page 2 from pagination menu