You’re almost there mate. Try this though.
<?php
add_action('pre_get_posts', 'filter_press_tax');
function filter_press_tax( $query ){
if( $query->is_tax('press') && $query->has_term('press')):
$query->set('posts_per_page', 5);
return;
endif;
}
?>
You can use any conditional tag or any argument that can be passed to WP_Query
to test your condition or set a new value via pre_get_posts
. Also try $query->get('taxonomy')
/ $query->get('term')
.
And check this for $query
‘s set and get methods.
Related Posts:
- Using pre_get_posts for taxonomy post count
- How can I completely hide a taxonomy term from “frontend”? [closed]
- Exclude taxonomy Query if post_type
- Can the default “post tags” taxonomy be renamed?
- Custom columns for taxonomy list table
- How to organize and cache additional data associated with terms?
- Better way to enforce category hierarchy in post_categories_metabox?
- Child Terms not Displaying on the Taxonomy Term Admin Screen
- List all taxonomy terms / Show links if posts are attached, else names
- How to overwrite a specific parameter in a core taxonomy?
- Set a cookie in WordPress, using a select form and Jquery
- How to add terms to taxonomy with wp_insert_terms?
- How to add automatically keyword to taxonomies when a post published, and assign them to the post
- Display Custom Taxonomy in Sidebar in Two Columns
- Retrieve taxonomy terms in order of their post’s date?
- Custom taxonomy archive – No posts found [closed]
- Display parent taxonomy name and list child taxonomies below it?
- Conditional tag affecting taxonomy term and its children?
- Custom template for archive of a custom taxonomy
- Getting the parent from the wp_term_taxonomy
- Taxonomies, restrict editing and creation of terms?
- Variable in Array Not Working
- Add current class to queried term on taxonomy term archive
- How to list 2 taxonomy terms for a post, based on their hierarchy
- Showing custom taxonomy column in taxonomy category listings immediately after create category
- Order wordpress taxonomy parent terms by their children count
- how to get the assigned child term of the term’s parent
- Plugin to assign parent category on multiple taxonomy terms
- Pagination on taxonomy archive pages breaks
- how to show only last child terms of a taxonomy
- Check for taxonomy archive on search results page
- Use a CPT as a taxonomy
- How to list taxonomy terms in reverse order?
- how to display only the sub category names of the taxonmoy
- Adding tag’s featured image to tag archive
- Group Post by Custom Taxonomy 2 under Custom Taxonomy 1
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- Ordering Taxonomies / Changing term_id
- How to restrict users in edit post that can just select exists tags? not add new
- Changing the default taxonomy key length
- Adding taxonomy terms based on custom field
- Multi Taxonomies same terms
- UI for taxonomies & query vars
- Exclude posts with taxonomy term from appearing on home page query
- How to enforce the selection of at least one term from a custom taxonomy?
- Display a tag only if there is a description
- Query Custom Post Type by Taxonomy Meta Value
- Retrieve Taxonomy Label
- Foreach inside foreach
- Return Taxonomy Name for Each Term
- Taxonomy list names with lowercase
- Get term from multiple taxonomy
- Modify output of wp_dropdown_categories to add term IDs to each option
- Repeater + taxonomy: same value in every field
- line order number start numbering from second line (SOLVED)
- How to display only the direct children of a term on a taxonomy page
- Display posts from tagchildren of taxonomy tagparents
- If has_term, load other theme
- Terms from current post custom taxonomy — excluding parent and only from a single parent term
- archive page sidebar not working
- Bug using wp_insert_term with switch_to_blog
- how to list parent terms only
- Related Taxonomy Doesnt Show any Posts
- Get something out from taxonomy
- get_term_by with a variable
- Get ACF taxonomy term and sub-term lists ACF blocks
- Change searching from world level to first letter
- Finding id of taxonomy by name in custom post type
- How to have article URL like example.com/article1 and example.com/foo/article2?
- Unique IDs for Post Types and Taxonomies
- JS POST update data taxonomies
- Can’t display multiple terms with get_the_terms
- I want to edit the tags template by adding text that displays all tags from the listed posts
- Get Term ID by Description
- Can lots of tags affect performance?
- echo a tax term in loop
- I need posts within a taxonomy category that are tagged “featured” to show up first
- how to echo a custom taxonomy term from an array of term
- How to manage the links of a new taxonomy
- How to position taxonomy meta box on page
- WP REST API taxonomy is missing on custom post type
- Get taxonomy url, name, post count & image
- Rewrite permalink to include multiple taxonomies
- taxonomy terms are not populating select tag options
- Recent posts by taxonomy and filter by tag
- How to show amount of post in a taxonomy with advanced custom fields?
- Related Posts by taxonomy using Advance Custom Fields Plugin
- Organize content by month? SQL statement?
- Display Custom Column in CPT Taxonomy
- get term slug from current posts’s custom taxonomy
- Output Taxonomy Title as Part of Result
- Help me add Taxonomy to byline
- Add a tag like a post
- How Can I List Categories by Date?
- Custom Taxonomy Page redirect 404
- Passing values by form to create a query
- Why is taxonmy-[taxonomyname].php not working?
- Taxonomy link not working (leads to 404 page)
- Custom Titles for Multiple Tag Taxonomy Page
- Add new taxonomy in WP without generate any url