Using your custom get_posts()
you are ignoring the $paged
var. In this way, you’ll see always posts from the first page.
According the Codex Page if you would like to alter the main query before it is executed, you can hook into it using pre_get_posts
.
function my_post_queries( $query ) {
if (!is_admin() && $query->is_main_query()){
$query->set('posts_per_page', 10);
$query->set('post_type', array('news'));
$query->set('orderby', 'date');
$query->set('order', 'DESC');
}
}
add_action( 'pre_get_posts', 'my_post_queries' );
In this way the $paged
var is maintened from the main query.
You can also check if the main query is in a specific archive or whatever, in the hook function.
Related Posts:
- paginate function in archive for custom-post-type
- Custom post type archive page pagination
- Pagination not working for archive
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Custom post type pagination 404 fix?
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Pagination throws 404 error on custom taxonomy archive pages
- Proper way of making custom post type landing page or archive page
- Custom Post Type Archives by Date with Custom Permalink
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Change title in head on Archive page
- Custom Post Type Archives with 0 Posts Redirects as 404
- Multiple Paginations on one Page
- Archive page…limiting posts per page
- Page is defaulting to archive page and not designated template
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Custom Post Type Archives by Date (stored as meta value) WP3.1
- Custom post type archive with pagination?
- Custom post type archive sorted and grouped by date in post meta field
- How to create archive page for taxonomy terms within custom post type
- WordPress custom post type archive with description
- Custom-post-type-archive: posts sorted/filtered by year?
- How to list custom post types?
- Editable content on a Custom Archive page
- Second Custom Post Type Archive
- is_main_query() not working for WP REST API
- CPT Archive with core Category
- How can i change the output of posts_nav_link();
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- get the custom post type title/name
- URL of a custom post type’s post format archive?
- Create template for taxonomy results limited by Custom Post Type
- Custom post type archive page blank
- How to display custom post in archive section of the wordpress page?
- What’s the name of the custom post type yearly archive template?
- How can I use archive-{post_type}.php theme template?
- Return the name of the post type
- Use the custom post type archive for taxonomies?
- Custom Post Type Archive Pagination
- Archive page for custom post type and custom taxonomy
- How to have multiple archive pages?
- Create a Custom Path to Archive
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- WordPress sitemap with Custom Post Types
- Is possible register two archive pages for single custom post type?
- pagination problem listing custom post types of taxonomy in wordpress
- Custom Post type page content (archive page)
- Group custom post type posts by month
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Do not show child pages within a file page
- Tell wordpress to show a single page instead of an archive page
- Permalink for custom post type pages not working
- Custom Post Type archive page listing a 404 or single post
- Custom post pagination not working
- Custom post type pagination problem – page 1 and 2 show same content
- Want to display my custom date archive to date.php but dont know how
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- Custom taxonomy in custom post type archive with pagination
- why custom post archive gives always no more than 10 posts despite of paging settings?
- Rewriting archive page slug to be different than custom post type slug
- Pagination fault in custom post type archive page [duplicate]
- Site loads very slow for archive custom post type page
- Stop Custom post type from being searched via URL
- Custom post type category page not working
- How can I set up the URL for a category archive for a custom post type?
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- Archive Page Pagination not working
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Remove plugin’s custom post type archive page and single pages [closed]
- Pagination not working only on Archive-Name.php using new WP_Query
- Pagination not working on custom post type archive
- Archive pagination – second page shows exactly the same posts
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- Custom Post Type Settings page, choose page to display archive
- Adding custom post type archives to a WordPress menu
- wp_pagenavi() with custom wp_query()?
- pagination redirecting from page number url before page requested
- How can I filter by taxonomy on a custom post type’s page?
- Custom post types and tag archive pages/permalink structure issue
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- WordPress showing archive.php instead page
- can these 3 queries be re-written as 1 query?
- Assign CPT archive page attributes
- Custom post type and custom taxonomy 404 on page 2
- How to constrain the results to a specific post_type on tag archive page?
- add_action ‘init’ from inside a class for custom post types
- Custom post type archive – error in nav-menu-template.php
- Pagination for custom post type giving 404 error (but only for news page)
- how to skip a CPT element from the pager by custom field
- Posts per Page on custom Taxonomy Template
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Turning archive templates to a page template maintaining the slug
- Custom Post Type / Taxonomy / Term – what template to use to avoid 404-page?
- Pagination not working (page/2 retunring 404 page)
- How to manage a custom post type archive as a page?
- query and paginate multiple post types
- Custom Post Type Pagination Problem in Admin Section
- Rewrite rules causing hole
- the_post_navigation in single page with multiple taxonomies