You can use pre_get_posts
action to achieve that:
add_action( 'pre_get_posts', function ($query) {
if ( ! is_admin() && is_archive() && $query->is_main_query() ) {
$query->set( 'posts_per_page', 100 );
}
});
In the code above I use is_archive()
, but you can use other conditional tags in there…
Related Posts:
- $query->set in pre_get_posts is unintentionally affecting the backend
- Custom post type archive sorted and grouped by date in post meta field
- Custom post type with tags
- pre get posts changing the query
- Using pre_get_posts to Filter Posts
- How to modify archive query with pre_get_posts to append CPTs?
- pre_get_posts works in post type archive but not in single post
- How to enqueue scripts on custom post add/edit pages?
- remove custom post type permalink
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Custom post type pagination 404 fix?
- Adding content to archive and taxonomy pages on custom post types?
- Filtering a custom post type by custom taxonomy in archive template
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- get term archive url / link
- Prevent pre_get_posts filter on specific post type
- How to get the custom post type from an archive page?
- How to remove “Archive:” label from archive title
- Why are posts from custom post type not displayed in “category” archive?
- Custom Post Type Archives by Date and Taxonomy
- Displaying category archive of custom post types
- Custom post types – Use post_id in permalink structure when using has_archive => true
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Pagination throws 404 error on custom taxonomy archive pages
- Action hook on Edit custom post type?
- Setting up custom post type archives in WP3.1? Any luck?
- Proper way of making custom post type landing page or archive page
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- Custom Post Type Archives by Date with Custom Permalink
- Unregister post type from child theme
- Custom post type save_post action not firing
- Filter for “get_post_type_archive_link()”
- How to correctly get post type in a the_title filter
- How to put custom post types on front page
- How to intercept publish post for a custom post type “event”
- How to add meta box to backend menu page
- Why The Init Hook For Custom Post Types
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- Add Custom Post Type to Current Query
- Change title in head on Archive page
- Display Editable Text Above CPT Archive Listings
- Custom Post Type Archives with 0 Posts Redirects as 404
- Archive page with multiple taxonomies rewrite
- Include post id[s] into WP_Query()
- Pre get posts for single post
- Multiple Paginations on one Page
- Create permalink structure for one taxonomy archive per custom post type
- Archive page…limiting posts per page
- WP 3.1 – archive pages for custom content types possible now without a plugin?
- Page is defaulting to archive page and not designated template
- Date archives for custom post type
- How to get my Custom Post Type to display in Recent Posts using “pre_get_posts”
- Custom Post Type Archive URL takes over page URL
- Custom comment status possible?
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Display all custom post types in archives.php
- With what hook can I address all posts from all custom post types when they are published?
- Pre_get_posts Gives 404 on Custom Post Type
- Make the ‘all’ filter default instead of ‘mine’ in a custom post type
- How to Add Pages Under Custom Post Type URL Structure?
- Dynamically Create Terms in Taxonomy when Custom Post Type is Published. Almost There!
- Custom Post Type Archives by Date (stored as meta value) WP3.1
- WordPress custom post type category pagination 404 Error
- filter search result with custom post type meta key
- Order posts by (hierarchical custom) taxonomy terms and term children
- Custom Permalinks for Custom post Type Archives?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- is_singular won’t call my functions?
- Show Custom Post Type by Author
- WordPress Custom Shortcode Conflicting with Media Library
- Custom post type archive with pagination?
- Custom post type tag archives don’t work for basic loop?
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Removing CPT slug from URL results in 404 error for archive page
- Multiple post types in archives (filter?)
- Pages, Custom Posts & Custom Taxonomy defining slug structure
- How to show a tag archive of one post type only
- How to let custom post type posts show in standard post archive (like in homepage)?
- Regex problem in an add_rewrite_rule
- paginate function in archive for custom-post-type
- Limiting number of custom posts shown on taxonomy page
- Custom taxonomy archive page not working
- Include custom post type in “all posts”
- Include Custom Posts Type in Year/Month/Date Archive
- WordPress custom post action hook
- Change plugin’s has_archive = true to false?
- where can I see my custom post type archive template?
- action init hook and get_post_types
- Can’t sort order of wp_query with 2 meta keys
- wrong template for page of archive
- Sort custom post types by last name in the backend
- Displaying custom post type on category pages but not on blog listings
- How to show multiple post types on taxonomy archive?
- Call different archive page based on post type
- Disable single pages and archives and keep preview
- What hook should be used to programmatically create a post only when master post is updated?
- How to register custom post types in a plugin?