is_category('category-name') won’t work until after the query is run. If we check source code where those notices are generated, we can see that it’s using get_queried_object, which gets populated with the results of the main query, and at the pre_get_posts stage will still be empty.
As an alternate, check the contents of $query->query_vars, which will be an array of query vars parsed from the requested URL.
Related Posts:
- is_category() in pre_get_posts strange error
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Include posts from feature category in pre_get_posts
- Category param redirect to post type archive
- Rearranging posts based on categories
- How do I edit pre_get_post for the category the user is currently in?
- Custom Query to search through categories
- How to query all posts of a specific category, and any other category combination
- Query the Loop without breaking it
- How to Check if a Child Category is Being Queried
- How Do I Merge Categories With phpMyAdmin
- If newest post of category is newest post in general, skip first post of category
- Disallow categories from this MySQL query
- How to display posts under a specific subcategory of a given category
- get_the_category and echo out link to child-most/deepest category
- query in category.php repeats itself
- Display posts separated by Category in Author’s page
- How to get related tags based on a category?
- Show popular post by category code
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- How to get latest posts from each category in regular order
- category pagination got broken suddenly
- How to query categories with Advanced Custom Fields?
- Where and when does WordPress invoke routes
- And/Or Category Query
- Exclude category by slug in pre_get_posts?
- Exclude category from query
- Overriding default calendar to show posts from a category
- Filter WooCommerce archive pages by an additional category
- Custom tax_query filter not working for Woocommerce product categories
- function query_posts disabling current_page_menu class
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Using in ‘category_name’ in ‘$query->set();’?
- custom query for both category and pages using global $wpdb;
- Get categories of queried posts
- Query from multiple category (and)
- How to display posts from specific category using get_option function?
- SQL query to get posts from multiple categories but not in a category
- Conditional category query breaking?
- How to filter post from categories only if the posts appears in one of them, not the other?
- Category name for all posts getting assigned to a single random post
- Show Posts via cat+cat in URL that are in both Categories doesn’t work
- `offset` WP_Query argument dont work via `pre_get_posts`
- List of post categories only associated to another custom taxonomy
- Sort categories by custom field in WordPress admin
- how tho change number of posts in loop from specific categories
- Change post category within pre_get_posts
- Get category from slug list
- Issue with WordPress category search
- Querying posts from two different categories while looping inside another loop
- how to get postmeta info based on multiple categories?
- Too many categories drastically slow down my website
- How to get posts from many categories using WP_Query
- Is it possible to query the result of a query?
- show posts found in multiple categories via category_name query string?
- Help with SQL query, how to add taxonomie terms with value stored in options?
- Match two taxonomies to display a specific content
- Category slug in in loop always the same?
- Create Cross Promoting Categories in WordPress Using ‘pre_get_posts’
- display certain category on custom template page
- Detecting top parent category fails on home page
- How to use Greek characters/letters in a query?
- Displaying posts by year
- wordpress category.php query for featured news item, broken pagination and repeating posts
- How to show posts of a specific category
- How to get parent and child sub category (Taxonomy) order to display
- Get Category ID inside Category template
- Posts URL structure like site.com/category/the-post-title
- pre_get_posts with get_posts
- How to display wp_list_categories on div instead of li?
- Get posts from child categories with parent category ID
- How to Make a Categories Meta Box with Hierarchical Checkboxes on Frontend?
- Add search to list of categories in post editor
- How to? Redirect /category/sci-fi/ to /category/scifi/?
- Sort category page with custom field
- Exclude a category from the filed under list only on some templates
- Redirecting category link to first child post
- Add specific word before the category page title
- Display one latest post from multiple categories
- Archive pagination causing 404 with permalinks structure
- Get a list of Terms for a specific category
- Get a variable from object in array [closed]
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- Exclude Child Categories Using wp_list_categories
- Show category children, one level
- a-z list, categories and sub categories in loop
- Category slug $_SERVER[‘REQUEST_URI’];
- wp_dropdown_categories and custom taxonomy + custom post type
- Linking products to categories
- How to remove “Category : …”
- Show all posts for a specific category/author
- How to call custom category field data in theme?
- Query Posts Exclude Entire Category
- One Specific Category To Permalink
- Hide woocommerce category name from specific pages
- WordPress category widget only show categories with children
- Woocommerce custom category page with pagination [closed]
- Menus don’t work after 4.4 [closed]
- Custom post and category template pagination problem
- Images as Categories