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
- Custom post type pagination 404 fix?
- Filtering a custom post type by custom taxonomy in archive template
- get term archive url / link
- How to get the custom post type from an archive page?
- How to remove “Archive:” label from archive title
- Proper way of making custom post type landing page or archive page
- How to correctly get post type in a the_title filter
- How to intercept publish post for a custom post type “event”
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- Display Editable Text Above CPT Archive Listings
- Custom Post Type Archives with 0 Posts Redirects as 404
- How Do I Use WP_Query to Run This Database Query as Search Result?
- paginate function in archive for custom-post-type
- Limiting number of custom posts shown on taxonomy page
- Include custom post type in “all posts”
- How to create archive page for taxonomy terms within custom post type
- Category and post tag archives do not include posts from custom post type
- Slug for standard post post_type
- Remove “Get Shortlink” button in admin of custom post type
- update_post_meta() whenever custom post type is updated
- How to get Custom Post ID by adding filter to child theme’s function
- WordPress custom post type archive with description
- Get post type from taxonomy or category page
- How to list custom post types?
- custom taxonomy archive by year
- Display CPT description on archive.php pages for all CPT
- When ‘is_post_type_archive()’ return true?
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Using pre_get_posts to filter one loop in a multiloop archive
- Change archive page template using pre_get_post
- Custom Post Type Archive Page Filtering
- Advanced or not so advanced pre_get_posts query
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- URL of a custom post type’s post format archive?
- Create template for taxonomy results limited by Custom Post Type
- Showing posts from different categories and from custom post type
- WordPress showing archive.php instead page
- Custom Post Type Archive Error, Takes Last Post as Title and Doesn’t Work
- Is it better to use filter for the_content in archive pages?
- Create new custom post and post category of same name
- Archive not sorting correctly
- What’s the name of the custom post type yearly archive template?
- multiple custom post type on category page
- Use remove_meta_box conditionally on custom post type
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- How do I amend form data before it is saved for a custom post type
- Assign CPT archive page attributes
- Custom taxonomy or custom page templates?
- Can anyone clarify difference between archive-{posttype}.php, type-{posttype} and date.php?
- how to show records that don’t have custom meta value
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- Use the custom post type archive for taxonomies?
- Display Date & Author Info on Custom Post Type Archive Page
- 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 Date Based Archive URL rewrite [duplicate]
- How can I tell if I’m on a custom post type archive page?
- Order posts by taxonomy terms
- Custom Post type page content (archive page)
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Group custom post type posts by month
- Post Click Redirect to Custom URL instead of Single Post Page
- How to hide private posts even if user is admin
- Custom WordPress theme not displaying posts from category
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Custom post types not showing on the standard WordPress Category page
- Turning archive templates to a page template maintaining the slug
- Order archive custom posts by taxonomy term [duplicate]
- Custom Archive – hide posts until a search is made?
- CPT year wise archive based on custom date Field
- Apply pre_get_posts to specific custom post type in the admin area
- Custom Post Type tag taxonomy “Page Not Found”
- Custom Post Search
- do action inside a class is not working
- Filter wp_dropdown_categories Per Post Type
- pre_get_posts with multiple post types AND a meta_key
- Custom Post type archives / categories give 404
- Fetch post meta in the same query as the main loop
- Archive.php is not displaying tags
- Problem to show custom post type in archive page category wise
- Adding custom post types to the default loop, yet only posts that has terms from the core taxonomies
- Custom post type category page not working
- Custom post types with date based archive
- custom post types, pre_get_posts, wp_list_categories
- paging is not working properly on news archives page [duplicate]
- Categories in custom post types
- is_singular won’t call my functions?
- How to turn custom-post archive into an overview page, listing the metadata of the posts?
- how to pass args for archive.php query?
- 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]
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query