You can achieve it with pre_get_posts
. With your current code there are multiple syntax errors. You have write it this way
add_filter('pre_get_posts', 'limit_change_posts_archive');
function limit_change_posts_archive($query){
if ( !is_admin() && $query->is_main_query() && is_archive() && is_tax( 'pdsh_categories' ) && is_term( 1858 )) {
$query->set('posts_per_page', -1);
}
return $query;
}
As is_term
is deprecated a different approach can be like this:
add_filter('pre_get_posts', 'limit_change_posts_archive');
function limit_change_posts_archive($query){
if ( !is_admin() && $query->is_main_query() && is_archive() && is_tax( 'pdsh_categories', 1858 )) {
$query->set('posts_per_page', -1);
}
return $query;
}
Again this above code needs to be tested.
Related Posts:
- How to use a custom post type archive as front page?
- CPT archive admin menu label
- How to add specific terms in a custom post type?
- Pagination fault in custom post type archive page [duplicate]
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- How to change default position of WP meta boxes?
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Archive Page not showing
- Custom post type yearly/ monthly archive permalinks
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Search everything (posts, pages, tags, cpt, meta)
- Custom post type permalink structure with the category also acting as an archive
- Rewrite custom post type url’s adding meta box values
- Automatically assign a custom post to a custom taxonomy based on custom field value
- Exclude Custom Post Type & Pages From Auto-Tag Function
- Add meta data to the custom post type ARCHIVES page
- Custom Post Type archive giving 404
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Post the content of a specific “Custom Post Type” post within a post using a shortcode
- add_rewrite_endpoint() and Custom Post Type Archive
- Custom post type archive page pagination
- How to change the admin menu “Pages” to something else
- Apply post formats to a specific post type only?
- How do I get the permalink structure to work like this?
- Loading all files within a directory
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Custom Post Type with has_archive ignores my custom archive and single template
- Archives for Custom Post Types (without Pages)
- What’s the difference between same wp functions get_posts(); functions in different form?
- Function to display custom post type on front page makes menu items dissapear
- Custom Post Type with Templates using Meta Boxes?
- Extending AZIndex plugin to use custom post types and custom taxonomies
- Redirect 404 page with ID in slug to associated page with same ID in slug
- Display featured image from one CPT within another CPT query
- Anon function and add_meta_box
- Shortcode not working with post counter
- Changing default ‘posts’ parameters with register_post_type_args
- Allow users to create posts without logging in?
- Load scripts based on post type
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- custom post type metaboxes not saving
- Set thumbnail and title for a post type archive (not post itself!)
- Showing custom post type categories in the menu
- How to use a variable as a function name?
- How to integrate single and archive templates for custom post type in any WordPress theme
- Show categories of custom post type and not all posts
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- posts within custom post type all share the same content in the front-end
- Shortcode to return single custom post based on post taxonomy
- Using Wp_Query, Json to add Highcharts series data
- Custom Post Type with Configurable Sidebar via ACF
- Query Posts that have Custom Taxonomy
- Let users upload image(s) to the post from front end
- Archive page for custom post type and custom taxonomy
- Have custom post type Visibility be private by default, and have radio button also set to “Private”
- Pagination does not work on Custom Post Type archive while trying to get load more function working
- Sorting custom post types in edit.php : Post disappear
- Page template that uses lightbox to display post images
- Create a Custom Path to Archive
- Function to allow single post template based on custom taxonomy?
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Archive page of CPT’s custom Taxonomy
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Custom Form / Search with Custom Post Type Data
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- Custom post type archive URLs with a single taxonomy
- Custom Post Type / Taxonomy not displaying archive
- Cannot display the_content() after removed WordPress 5’s auto embed feature (iframe & blockquote)
- Update main post with same category when creating custom post to update the modified date
- pagination problem listing custom post types of taxonomy in wordpress
- Attend event form with ajax
- Permalink for custom post type pages not working
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Function for when new custom post type is created should do something
- Meta_query by date for Events archive
- When post is Published, insert into custom table a number – custom post type
- How to mark posts as visited
- Customize url from the_terms
- Want to display my custom date archive to date.php but dont know how
- Help with Multi Level Category Archive Page
- Custom post type archive page not showing on archive-posttype.php
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- Display custom post type archive on page.php template
- Set the Title of a Custom Post Type by code as Author’s Username
- Templates list in “Page Attributes” metabox is inaccurate
- Stop Custom post type from being searched via URL
- Permalink of custom post type partly broken
- Can’t preview custom post – Redirected to home page
- Custom taxonomy archive page not routing?
- Custom Loop for custom post type. Compare by meta_value?
- Post AND page parameter for WP function
- Pagination not working for archive
- How to string lines from the_content() hook in WordPress?
- Pagination not working only on Archive-Name.php using new WP_Query
- How to I add count of custom posts listed in a post as a prefix to its title
- Pagination not working on custom post type archive
- Best practice to display a list/archive of Custom Posts in a Page Template
- add_rewrite_rule not working with custom post type
- Archive pagination – second page shows exactly the same posts